// JavaScript Document
function getCatid(){
	    var vars = [], hash;
    //var hashes = window.location.href.slice(window.location.href.indexOf('#') + 2);
	var hashes =window.location.href;
	var mySplitResult =hashes.split('products.php');
	if(mySplitResult[1]!=''){

		var DataInfo=mySplitResult[1].split('&');
		var CatInfo=DataInfo[0].split('cat=');
		var CategoryName =CatInfo[1];
		
		var CatId=DataInfo[1].split('p=');
		var CategoryId =CatId[1];
		
		return CategoryId;
	}
}

function updateSubmenu(menuSize,id){
	$('#'+id).addClass('submenuActive');
	for(var i=1;i<=menuSize;i++){
		var temp='submenu'+i;
		if(  temp != id){
				if($('#'+temp).hasClass('submenuActive')){
					$('#'+temp).removeClass('submenuActive');
					}
		}
	}
	
	}
function getUrlVars()
{
    var vars = [], hash;
    //var hashes = window.location.href.slice(window.location.href.indexOf('#') + 2);
	var hashes =window.location.href;
	var mySplitResult =hashes.split('products.php');
	if(mySplitResult[1]!=''){

		var DataInfo=mySplitResult[1].split('&');
		var CatInfo=DataInfo[0].split('cat=');
		var CategoryName =CatInfo[1];
		
		var CatId=DataInfo[1].split('p=');
		var CategoryId =CatId[1];
	
		UpdateSumbenu(CategoryName,CategoryId);
		}
}
function UpdateSumbenu(cat,p){
	switch(cat){
			case 'maccaw':
			document.getElementById('unoSubmenu').innerHTML="Discover the flavors of UNO for the whole family! ";
			document.getElementById('icebergSubmenu').innerHTML='Discover more than 60 different flavors! ';
			document.getElementById('milkshakeSubmenu').innerHTML='You favourite Ice Cream in a chocolate milkshake!  ';			
			getPage('maccawSubmenu', 'maccawsubmenu.php?p='+p);
			  break;
			case 'uno':
			document.getElementById('maccawSubmenu').innerHTML="LibanJus' flagship brand, Maccaw, is the culmination of 50 years of juice know-how and experience in one bottle.<br />A premium juice like you've never tasted.  ";
			document.getElementById('icebergSubmenu').innerHTML='Discover more than 60 different flavors! ';
			document.getElementById('milkshakeSubmenu').innerHTML='You favourite Ice Cream in a chocolate milkshake!  ';				
			getPage('unoSubmenu', 'unosubmenu.php?p='+p);
			  break;
			case 'iceberg':
			document.getElementById('maccawSubmenu').innerHTML="LibanJus' flagship brand, Maccaw, is the culmination of 50 years of juice know-how and experience in one bottle.<br />A premium juice like you've never tasted.  ";
			document.getElementById('unoSubmenu').innerHTML='Discover the flavors of UNO for the whole family! ';
			document.getElementById('milkshakeSubmenu').innerHTML='You favourite Ice Cream in a chocolate milkshake!  ';			
			
			getPage('icebergSubmenu', 'icebergsubmenu.php?p='+p);
			  break;
			case 'milkshake':
			document.getElementById('maccawSubmenu').innerHTML="LibanJus' flagship brand, Maccaw, is the culmination of 50 years of juice know-how and experience in one bottle.<br />A premium juice like you've never tasted.  ";
			document.getElementById('unoSubmenu').innerHTML='Discover the flavors of UNO for the whole family! ';
			document.getElementById('icebergSubmenu').innerHTML='Discover more than 60 different flavors! ';
			getPage('milkshakeSubmenu','milkshakesubmenu.php?p='+p);
			  break;			  
			}	
	}
function changeURL(cat, p){
	$.address.value('cat='+cat+'&p='+p);
	UpdateSumbenu(cat,p);

} 
function getFlashMovie(movieName) {   
var isIE = navigator.appName.indexOf("Microsoft") != -1;   return (isIE) ? window[movieName] : document[movieName];  
}  
function LoadProducts() {   
getFlashMovie('swf').loadProd();    
}  
function ClearPartner(){
	document.getElementById('Name').value='';
	document.getElementById('Email').value='';
	document.getElementById('Phone').value='';
	document.getElementById('Message').value='';
	document.getElementById('Company').value='';
	document.getElementById('Position').value='';
	}
function ClearContact(){
	document.getElementById('Name').value='';
	document.getElementById('Email').value='';
	document.getElementById('Phone').value='';
	document.getElementById('Message').value='';
	document.getElementById('Subject').value='';
}

function getPage(target,Page){
       $("#"+target).html("<table cellpadding='0' cellspacing='0' border='0'><tr><td align='center' style='padding-left:35px;'> <img src='images/loading.gif' ></td></tr><tr><td align='center' style='font-size:11px'>Loading...</td></tr></table>")
	   $.ajax({
                 url: Page,
                 cache: false,
                 success: function(html){
                       $("#"+target).html(html);
                 }
       });
}
function getTheContentForAjax(method,url_to_send,parameters_to_send){
	var div_msg = document.getElementById('player-video-ids');
	
	$.ajax({
	      url: url_to_send,
	      global: false,
	      type: method,
	      data: parameters_to_send,
	      dataType: "html",
	      success: function(msg){
	      	if(msg == '0'){
	      		div_msg.innerHTML = '';
	      		alert("Something wrong happened !!! Please try again later");
	        	return false;
	      	}
	      	else{
//	      	  	div_msg.innerHTML = msg;
				var url_to_play = "../uploads/video/video/"+msg;
				LoadFlash(url_to_play);
	         	return false;
	      	}
	      },
		  error: function(msg){
		  	div_msg.innerHTML = '';
			alert("Something wrong happened !!! Please try again later");
	        return false;
		  }
	   }
	)
}


// load swf objects //
function LoadFlash(url_to_play){
//	alert(url_to_play);
//	alert(getFlashMovie('swf'));
	getFlashMovie('swf').loadFlv(url_to_play);
}
//////////////////////
