//Highlight image script- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use

/*------------------------------------------------------------------------------
Description: Function for selecting Main tabs 
------------------------------------------------------------------------------*/
function tab_in(callerObj,selected_id,type,value)
{
	//get the main tab row    
    var mainTabRowObj = callerObj.parentNode;
	
    // get the available TD nodes
    var tabArray = mainTabRowObj.getElementsByTagName("a");
    //filter only tabs that has tabmenu class
    for(var i=0; i<tabArray.length; i++){
        if (tabArray[i].className == "tb_active")
		{			
			tabArray[i].className = "tb_inactive";			
		}		   
		
		if (tabArray[i].id == selected_id)
		{			
			tabArray[i].className = "tb_active";			
		}	
    }		
	//-----------------------------
	//pulling the selected content
	//-----------------------------	
	getContent_selected(type,value)		
}


/*------------------------------------------------------------------------------
Description: Function for activating enter keys in search
------------------------------------------------------------------------------*/
function isNumberKey_nav(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode;
	//alert(charCode);
    if (charCode == 13 )
	 {
		getSearch();		
	}	   
}

function getSearch(){
     
    var alertMsg = "Required Fields:\n";
	var search_keyword = document.getElementById('search_keyword_site').value;	
	if(search_keyword=="" || search_keyword=="Search")
	{
		alertMsg += "- Search \n";			
	}
			
	if(alertMsg != "Required Fields:\n")
	{
		alert(alertMsg);
		return false;
	}
	else
	{  	 	  
	   //parent.location.href='http://beta.therakeonline.com/search.php?par='+search_keyword;	   
	}
	
}


/*------------------------------------------------------------------------------
Description: Function for controling the display error pages
------------------------------------------------------------------------------*/
function get_error()
{	
  if (document.getElementById('error_page').style.display=="block"){
   	document.getElementById('error_page').style.display = "none";  
  }
}


/*------------------------------------------------------------------------------
Description: Handles the Domain search Keyword
------------------------------------------------------------------------------*/
function mouseLink(THIS, num)
{
	if(document.getElementsByTagName)
	{
		var rows = THIS.getElementsByTagName("td");
		for(i = 0; i < rows.length; i++)
		{
			if(num == 0)
			{
				rows[i].className = "over"; 
			}
			else if(num == 1)
			{
				rows[i].className = "out"; 
			}
		}
	}
}



/***********************************************
for implementing / adding item into shopping bag
************************************************/
function getCartnow(id_num,title,desc,price,qty)
{
	//----------------------------
	//start here 
	//----------------------------	  
		var url = "module/getcart.php";
		var pars = "id_num=" + id_num + "&title=" + title + "&desc=" + desc + "&price=" + price + "&qty=" + qty;
		//alert(pars);
		myAjax = new Ajax.Request( url, {method: 'get', parameters: pars,onComplete: ShowResponse} );			
	
}



/***********************************************
contacting ajax prototype and displaying result
************************************************/
function ShowResponse (originalRequest) 
{
	var newData = originalRequest.responseText;
	var update = new Array();
	//alert(newData);
	if(newData.indexOf('|' != -1)) 
	{		
		 update = newData.split('|');			
		//-------------------------------------- 
		 //GETTING ITEM ON CART
		 //--------------------------------------		
		 if(update[0] == "getcart")
		 {			    
		 
			var total_qty = document.getElementById('main-total-qty');
			total_qty.innerHTML = update[2];
			document.getElementById('view-cart').style.display="block";
									
			var where_to= confirm(update[2] + " item(s) in basket. Do you want to proceed to checkout?");
			if (where_to== true)
			 {
			   window.location="http://www.therakeonline.com/scart.php";
			 }
			else
			 {
			    //window.location="http://www.barbie.com";
			 }			
				
		 }		
		
	}
}



