/* Defult function */
<!-- Define Js variable Host path-->

//var webSiteJsUrl	=	'http://www.mixunit.com/front/';
//var webSiteJsUrl	=	'http://192.168.0.37/projects/mixunit/front/';

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/* Defult function END */


/* Search form submit function */
function searchFormSubmit(){
	document.searchForm.submit();

}

/* Image replace on prdouct detail page*/
function changeProductDisplayImage(value,selected,pid){
	//alert(value);
	changeProductmainImage(value,selected);
	 //changeZoomImage(value,pid);
	 
}

function changeProductmainImage(val,iVal){
	var pId	=	val;
	 $("#dispalyImageDiv").bind('mouseover', function() {
					$('#dispalyImageDiv').attr("src",'');
					 });
	$.ajax({
	   url: webSiteJsUrl+'display_zoomimage.php',
	   type: "POST",
	   data: "MainImage=Yes&pId="+pId,
	   success: function(msg){
			if(msg != ''){
				var mmg ;
				mmg=msg.split('+++');
			//	alert(mmg[1]);
				$("#dispalyImageDiv").attr("src", mmg[0]);
				
				 $("#dispalyImageDiv").bind('mouseover', function() {
					$('#dispalyImageDiv').attr("src",mmg[1]);
				  });
		   }
	   }
	 });

}

function changeZoomImage(val,pId){
	var selectedImage	=	val;
	var productId	=	pId;
	

	$.ajax({
	   url: webSiteJsUrl+'display_zoomimage.php',
	   type: "POST",
	   data: "MainImage=No&imageName="+selectedImage+"&productId="+productId,
	   success: function(msg){
			if(msg != ''){
		
			 $("#imageZoom").html(msg);
		   }
	   }
	 });


}
function showpopupforAccount()
{
	$.alerts.okButton="&nbsp;Cancel&nbsp;";	
	
		var comment="";
		var conf="";
		comment="<a href='https://www.mixunit.com/cgi-mixunit/sb/registration.cgi?func=1&storeid=*180fe19ac56f0da01b6fb96940bc&fromid=order.cgi&sbid=SSMSB1322677677.30631' style='color:#CC0000'>Register</a> if you are a new customer. <br><br> <a href='https://www.mixunit.com/cgi-mixunit/sb/registration.cgi?func=2&storeid=*180fe19ac56f0da01b6fb96940bc&fromid=order.cgi&sbid=SSMSB1322677677.30631' style='color:#CC0000'>Sign In</a> if you are an existing customer.<br><br>*Issues logging in? Please call 1-888-MIX-UNIT"
		conf="Welcome to MixUnit!";
		jAlert(comment,conf, function(r) {				
			if(r==true)
			{
				$('#popup_panel').hide();
				return false;
			} 
		});
		return false;
	
}
function callsplitforValue(value)
{
	var sp;
	sp=value.split(',');
	//alert(sp[1]);
	changeProductDisplayImage(sp[1]);
}


function checkColorSizeBox()
{ 	
	//alert($('#qty').val());
	//alert($('#sku').val());
	
	
	
	if ($('#sku').val()=='')
	{ 
		$.alerts.okButton="&nbsp;OK&nbsp;";			
		var comment="";
		var conf="";
		comment="Use the dropdown menu to select a color and size."
		conf="Please select a color and size...";
		jAlert(comment,conf, function(r) {				
			if(r==true)
			{
					return false;
			} 
		});
		return false;
	}
	else if( (isNaN( $('#qty').val()) || $('#qty').val()=='' ))
	{
		$.alerts.okButton="&nbsp;OK&nbsp;";			
		var comment="";
		var conf="";
		comment="Fill correct value in quantity field."
		conf="Please Fill Quantity...";
		jAlert(comment,conf, function(r) {				
			if(r==true)
			{
					return false;
			} 
		});
		return false;
	}
	else
	{
		
	//alert($('#sku').val());
		var sp;
		sp=$('#sku').val();
		var ser;
		ser= sp.split(',');
		//alert("ser   "+ser[0]);
		document.getElementById('sku1').value = ser[0];
		//alert("id   "+document.getElementById('sku1').value);
		//alert($('#sku').val());
			document.productDetails.method="GET";
			document.productDetails.action="http://www.mixunit.com/cgi-mixunit/sb/order.cgi";			
			document.productDetails.submit();
			return true;
	}
	return false;
	
}


function checkQuantityField()
{ 	
	
	if( (isNaN( $('#qty').val()) || $('#qty').val()=='' ))
	{
		$.alerts.okButton="&nbsp;OK&nbsp;";			
		var comment="";
		var conf="";
		comment="Fill correct value in quantity field."
		conf="Please Fill Quantity...";
		jAlert(comment,conf, function(r) {				
			if(r==true)
			{
					return false;
			} 
		});
		return false;
	}
	else
	{

			document.productDetails.method="POST";
			document.productDetails.action="http://www.mixunit.com/cgi-mixunit/sb/order.cgi";			
			document.productDetails.submit();
			return true;
	}
	return false;
	
}

function ShowHideBig(id)
{
	$('#small'+id).show();	
	$('#big'+id).hide();	
	
}

function ShowHideSmall(id)
{
	$('#big'+id).show();	
	$('#small'+id).hide();	
	
	
}
