// JavaScript Document
/* var mine = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no');
 if(mine)
    var popUpsBlocked = false
 else
    var popUpsBlocked = true

//alert(popUpsBlocked);

if(popUpsBlocked)
  alert('We have detected that you are using popup blocking software.');
else
	mine.close();
*/	
function callPage(val)
{
	window.location.href	= "destination/"+val;
}

function ChangeImg_over(val)
{
	if (val == 1)
		document.homeImg.src= "images/reserve_fn.jpg";
	else
		document.homeImg.src= "images/reserve_en.jpg";
}

function ChangeImg_out(val)
{
	if (val == 1)
		document.homeImg.src= "images/reserve_f.jpg";
	else
		document.homeImg.src= "images/reserve_e.jpg";
}

function bookmarkme()
{
	var txt = "Bookmark Us!";
	var url = this.location.href;
	var who = "http://www.ikartit.com";

	var ver = navigator.appName;
	var num = parseInt(navigator.appVersion);
	if ((ver == "Microsoft Internet Explorer")&&(num >= 4)) {
		window.external.AddFavorite(url,who);
	}else{
		txt = "Press (Ctrl+D) to Add to favorite!";
		alert(txt);
	}
}

function mycenteralpopwinVHS(fname,width,height)
{  
	var file
	var sWidth	= 200
	var sHeight = 200
	
	if(width.length > 0){
	sWidth = width;
	}
	else{
	width =100;
	}
	
	if(height.length > 0){
	sHeight = height;
	}
	else{
	height =100;
	}
	
	file = fname
	file =file	
	
	var wintop  =window.screen.availHeight;
	var winleft =window.screen.availWidth;
	wintop  =(wintop/2) -(height/2)
	winleft =(winleft/2) -(width/2)
	//wintop  = 0
	//winleft = 0
	
	if ( sWidth > window.screen.availWidth )
		{ sWidth = window.screen.availWidth; }
	if (sHeight > window.screen.availHeight )
		{ sHeight = window.screen.availHeight; }
	if ( parseInt(sWidth) < width )
		{ sWidth = width; }
	if ( parseInt(sHeight) < height )
		{ sHeight = height; }
	
	if ( navigator.appName == "Microsoft Internet Explorer" )
		{ window.open(file, "_blank", "status=no, scrollbars=yes, toolbar=no, resizable=yes, location=no, menubar=no, top=" + wintop + ", left= "+ winleft +", height=" + sHeight + ", width=" + sWidth); 
		}
	if ( navigator.appName == "Netscape" ) 
		{ 
		window.open(file,"_blank","scrollbars=yes,alwaysRaised,dependant,innerheight=" + sHeight + ",innerwidth=" + sWidth); 		 
		//window.open(file,"_blank","alwaysRaised,dependant,scrollbars=yes,innerheight=" + sHeight + ",innerwidth=" + sWidth); 
		}
}

 function checkEmpty(frm)
	{
		if(frmPartner.txtUID.value == '')
		{
			alert('Please enter email address.');
			document.frmPartner.txtUID.focus();
			 return false; 
		}	
		else
		{
			var str=frmPartner.txtUID.value;
			var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
			if (filter.test(str))
			{
			}
			else
			{
				alert("Please enter a valid email address!")
				return false; 
			}
		}
		if(frmPartner.txtPWD.value == '')
		{
			alert('Please enter password.');
			document.frmPartner.txtPWD.focus();
			return false; 
		}	
		return true;
	}
	

function verifyNumeric(which)
{
	var oldvalue = [''];
    if (isNaN(which.value))
    {
        if (oldvalue[which])
        {
            which.value = oldvalue[which];
        }
        else
        {
            which.value = '';
            oldvalue[which] = '';
        }    
    }
    else
    {
        oldvalue[which] = which.value;
    }
}


function validation()
{
 	var n1 = 0;
	var e1 = 0;
	if(document.frmNews.txtName.value == "")
	{
		alert("Please Enter Name...");	
		document.frmNews.txtName.focus();	
		return false;
		
	}
	else
	{
		r1 = 1;		
	}

	if(document.frmNews.txtEmail.value == "")
	{
		alert("Please Enter Email...");			
		document.frmNews.txtEmail.focus();	
		return false;
	}
	else
	{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.frmNews.txtEmail.value)){
		e1 = 1;	
		return (true);
		}
		else
		{
			alert("Invalid E-mail Address! Please re-enter.")
			return (false);
		}
		
	}	
	if(r1 == 1 && e1 == 1)
	{
		document.frmNews.submit();
	}	
	
}
 
function FillValues(frm)
{
	if (frm.chkFillHolder.checked)
	{
		frm.txtFName_B.value	= frm.txtFName_D.value;
		frm.txtLName_B.value	= frm.txtLName_D.value;
		frm.txtEmail_B.value	= frm.txtEmail_D.value;
		frm.txtAddress_B.value	= frm.txtAddress_D.value;
		frm.selState_B.value	= frm.selState_D.value;
		frm.txtPostCode_B.value	= frm.txtPostCode_D.value;
		frm.selCountry_B.value	= frm.selCountry_D.value;
		frm.txtPhone_B.value	= frm.txtPhone_D.value;
	}
	else
	{
		frm.txtFName_B.value	= "";
		frm.txtLName_B.value	= "";
		frm.txtEmail_B.value	= "";
		frm.txtAddress_B.value	= "";
		frm.selState_B.value	= "";
		frm.txtPostCode_B.value	= "";
		frm.selCountry_B.value	= "";
		frm.txtPhone_B.value	= "";
	}	
		
}

function displayBilling(val)
{
	var idPmtMethod		= val;
	var idPmtTr			= document.getElementById("idPmtTr");
	var idPmtT1			= document.getElementById("idPmtTr1");
	
	if (idPmtMethod == 3)
	{
		idPmtTr.style.display 		= "block";
		idPmtTr1.style.display 		= "block";
	}	
	else
	{
		idPmtTr.style.display 		= "none";
		idPmtTr1.style.display 		= "none";
	}
}

function CallSecurity(val)
{
	if (val == "Amex")
		document.all.CCsec.innerHTML = "(4 Digits above your account number on the front side)";
	else
		document.all.CCsec.innerHTML = "(Last 3 digits above signature at the back of your card)";
}

function CntryOthr(val)
{
	var idCountry		= document.getElementById("idCntry");
	
	if (val == " Others")
		idCountry.style.display = "block";
	else
		idCountry.style.display = "none";
}
	// Java Script functions for Compare Products 
function checkComparePrd() 
{   
	var total=0;
	var comp = document.frmcompare['compare[]'];
	if(comp.length>0)
	{
		for(var i=0; i < comp.length; i++)
		{
			if(comp[i].checked)
			total = total + 1;
		}
	}
	http.open("GET", urlComp + total, true);
	http.onreadystatechange = handleHttpResponseComp;
	http.send(null);
}
function frmSubmit(curPID,iPP)
{	//alert(curPID+"Val Ipp :: "+iPP);
	document.frmcompare.txtPID.value = curPID;
//	document.frmcompare.txtIpp.value = iPP;
	
	document.frmcompare.action='index.php';
	document.frmcompare.submit();
}

function handleHttpResponseComp()
    {   
		if (http.readyState == 4) 
		{
			  if(http.status==200) 
			  {
				//alert(http.status); 
				 var results=http.responseText;
				// alert(results);
				//window.location.reload( true );
					if(results == 0)
					{
						document.getElementById('redbold').innerHTML = "Please select any of the product to compare";
					}
					else
					{
						document.frmcompare.submit();
					}				
			  }
		   
		 }
   }
   
	function getHTTPObject() 
	{
		var xmlhttp;
		
		if(window.XMLHttpRequest)
		{
		xmlhttp = new XMLHttpRequest();
		}
		else if (window.ActiveXObject)
		{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			if (!xmlhttp)
			{
				xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
		}
		
		return xmlhttp;
	}
	var http = getHTTPObject();

function product_check(objProduct)
{ 
	var obProductList;
	var objProductVal	= objProduct.value;
	var objProductCheck	= objProduct.checked;
	obProductList	= document.getElementById("txtProductList").value;
	if(objProductCheck	== true)
	{
	  if(document.getElementById('redbold').innerHTML!= '&nbsp;') {
		 document.getElementById('redbold').innerHTML  = ""; }
		 
		 if(obProductList == ',' || obProductList == ',,' || obProductList == ',,,' || obProductList == ',,,,'){
		     obProductList = "";
		  }
		if(obProductList.length)
		{ 
			document.getElementById("txtProductList").value = obProductList + "," + objProductVal;
			
		}
		else
		{
			document.getElementById("txtProductList").value = obProductList + objProductVal;
			
		}
	}
	else
	{	
		strRep	= obProductList.match(objProductVal);	
		obProductList	= obProductList.replace(strRep, "");
		//alert(obProductList);
		document.getElementById("txtProductList").value = obProductList;
	}	
}

<!------------- To change the image on mouse over--------------->
function OnMouseOverShowChange(imagename,prdTitle,path)
{
		document.getElementById('imageName1').src   = path+"prodImg/n_"+imagename;
		document.getElementById('imghref').href		= "JavaScript:mycenteralpopwinVHS('"+path+"display_images.php?prod="+prdTitle+"&img="+ imagename +"','600','600');";
}


function change_blank()
{
	if(document.getElementById('txtToEmail').value == "Friends email address")
	{
	document.getElementById('txtToEmail').value='';
	}
}
/*function frmProductSubmit()
{
	var colorVal = document.frmProduct.selColor.value;
	if(document.frmProduct.selColor.value == "")
	{
		document.getElementById('errColor').innerHTML = 'Please selet colors';
		return false;
	}
	else
	{
		document.frmProduct.submit();
	}
}*/
 function formchecker(theForm,prdID,cpVal,stURL)
{
	var	eleProductId	= prdID;
	var	elecpVal		= cpVal;
	var num_of_elements = document.frmProduct.length;
	
	exSelect 	= 0;
	eleSetColor = 0;
	eleError	= "";
	eleString	= ""
	
	for (var i=0; i<num_of_elements; i++) {
		var theElement = document.frmProduct.elements[i];
		var element_type = theElement.type;
		var element_name = theElement.name;
		var element_value = theElement.value;
		
		//alert("in select ");
		
		//alert(element_type);
		//alert(element_name);
		
		if (element_type.indexOf("select") > -1) 
		{
			//alert("in select "+element_name+" Value : "+element_value);
			exSelect = 1;
			var index = theElement.selectedIndex;
			if (index <= 0) 
			{
				//alert("index : "+index);
				if(element_name == "selColor")
				{
					eleSetColor = 1;	
					eleError = 'Please select color';
				}
				else
				{
					eleSetColor = 2;
					eleName		= element_name;
					//eleNameNew	= eleName.substr(4);
					eleError 	= eleError+'<br>Please select '+element_value;
				}
				cntColorEx = 0;
				/*document.getElementById('errColor').innerHTML = 'Please select color';
				return false;*/
				
			}
			else
			{
				//alert("index else : "+index);
				eleString 	= eleString+"&"+element_name+"="+element_value
				eleString	= eleString.replace(",","-");
				cntColorEx  = 1;
				//alert("eleString : "+eleString);
				//break;
				//document.frmProduct.submit();
				
			}
		}
		else
		{
			cntColorNE	= 1;	
		}		
		/*else
		{
			//alert(" No Select color ");	
			document.frmProduct.submit();
		}*/
		
	}
		//alert(" exSelect : "+exSelect+" index "+index);
		//alert(" Error : "+eleError);
		if(eleError != "")
		{
			//alert("Mann here ");			
			//alert(eleError);
			//document.getElementById('errExvar').innerHTML = 'Please select '+eleName;
			document.getElementById('errExvar').innerHTML = eleError;
			return false;
		}
		else
		{
			if(elecpVal == 1)
			{
				document.frmProduct.submit();
			}
			else
			{
				window.location.href = stURL+"personalize-of-product.php?prodId="+prdID+eleString;
			}
		}
}

function frmWishlistSubmit()
{	
	var num_of_elements = document.frmListing.length;
	var chkCnt;
	chkCnt 		= 0;	
	attriCnt 	= 1;
	var exColorArr = new Array();
	var exAttriArr = new Array();
	for(i=0; i<document.frmListing.elements.length; i++)
	{
		var exColor	= 0;
		var exAttri	= 0;
		
		if(document.frmListing.elements[i].type=="checkbox" && document.frmListing.elements[i].checked==true)
		{
			theElement	= document.frmListing.elements[i];
			
			//exColor	= document.frmListing.hdColorVariant[i].value;
			//exAttri	= document.frmListing.hdAttriVariant.value;
					
			eleName	= theElement.name;
			//alert("Sub Str: "+eleName.substr(4,1));
			eleNameC	= eleName.substr(4,1);
			colorName	= "hdColorVariant_"+eleNameC;
			
			
			exColor	= document.getElementById('hdColorVariant_'+eleNameC).value;
			exAttri	= document.getElementById('hdAttriVariant_'+eleNameC).value;
			
			/*alert("elename : "+theElement.name+"Color Name : "+colorName);
			alert(eleNameC);
			alert(eleNameC+"Attri Val : "+exAttri);*/
			
			// color
			if(exColor == 1)
			{
				exColorVal	= document.getElementById('selColor['+eleNameC+']').value;
				//alert(eleNameC+"Color Val : "+exColorVal);
				if(exColorVal == "")
				{
					ColorCnt = 0;	
					//exColorArr.push("Kai Jim")
					exColorArr[chkCnt]	= 0;
				}
				else
				{
					//attriCnt 				= attriCnt + 1;	
					exColorArr[chkCnt]	= 1;
				}				
			}
			// attri
			if(exAttri == 1)
			{
				exAttriVal	= document.getElementById('selAttri['+eleNameC+']').value;
				//alert(eleNameC+"Attri Val : "+exColorVal);
				if(exAttriVal == "")
				{
					//attriCnt = 0;	
					exAttriArr[eleNameC]	= 0;
				}
				else
				{
					//attriCnt = attriCnt + 1;
					exAttriArr[eleNameC]	= 1;
				}
			}
			
			chkCnt = chkCnt + 1;			
		}		
	}
	
	var ColorErr	= "";
	if(exColorArr.length > 0)
	{
		for (count = 0; count < exColorArr.length; count++)
 		 if (exColorArr[count] == 0)
		 {
			 //alert(" error color ");
			 ColorErr	= "Please select variant";
			 attriCnt = attriCnt + 1;
		 }
	}
	if(exAttriArr.length > 0)
	{
		for (count = 0; count < exAttriArr.length; count++)
 		 if (exAttriArr[count] == 0)
		 {
			 //alert(" error color ");
			 ColorErr	= "Please select variant";
			 attriCnt = attriCnt + 1;
		 }
	}
	//document.write(exColorArr);
	//alert("chkCnt : "+chkCnt);
	if(chkCnt > 0)
	{
		//document.frmListing.submit();	
		if(ColorErr == "")
		{
			document.frmListing.submit();
		}
		else
		{
			document.getElementById("errWish").innerHTML	= ColorErr;
			return false;
		}
	}
	else
	{
		document.getElementById("errWish").innerHTML	= "Please select product. &nbsp;&nbsp; "+ColorErr;
		return false;	
	}
}

// Validation for Personalization 
function frmPersonalizeSubmit(obj,nLines,flag)
{
	var no_of_lines	= nLines;
	var validCnt 	= 0;
	var validCntNew = 0;
	chkCnt 			= 0;

	for(p=0;p<no_of_lines;p++)
	{
		/*f2	= document.getElementById('txtLine_'+p).value;
		alert(" Val of f2 : "+f2);
		if(f2 == "")
		{
			//alert(1);	
			validCnt	= validCnt + 1;
		}*/	
		f2	= document.getElementById('txtLine_'+p).value;
		//alert(" Val of f2 : "+f2);
		
		if(f2 != "" && f2 != "Your personalized message here")
		{
			//alert(1);	
			validCntNew	= validCntNew + 1;
		}
		
	}
	//alert(validCnt);
	if(validCntNew <= 0)
	{
		document.getElementById("errPerDisp").innerHTML	= "Please enter text.";		
		//return false;
	}
	else
	{
		document.getElementById("errPerDisp").innerHTML	= "";	
	}
	
//	chkReturnP
	if(document.frmProduct.chkReturnP.checked==true)
	{
		chkCnt	= 0;
		document.getElementById("errCheck").innerHTML	= "";	
	}
	else
	{
		chkCnt	= chkCnt + 1;
		document.getElementById("errCheck").innerHTML	= "Please select checkbox.";		
	}
	
	// check box validation 
	
	/*if(chkCnt <= 0 && validCnt <= 0)
	{
		document.frmProduct.submit();	
	}*/
	
	<!------------------- for drop downs -------------->
	exSelect	= 0;
	eleSetColor	= 0;
	eleError	= "";
	eleString	= ""
	
	if(flag == 1)
	{
		var num_of_elements = document.frmProduct.length;
		
		for (var i=0; i<num_of_elements; i++) 
		{
			var theElement = document.frmProduct.elements[i];
			var element_type = theElement.type;
			var element_name = theElement.name;
			var element_value = theElement.value;
			
			//alert("in select ");
			
			//alert(element_type);
			//alert(element_name);
			
			if (element_type.indexOf("select") > -1) 
			{
				//alert("in select ");
				exSelect = 1;
				var index = theElement.selectedIndex;
				if (index <= 0) 
				{
					//alert("index : "+index);
					if(element_name == "selColor")
					{
						eleSetColor = 1;	
						eleError = 'Please select color';
					}
					else
					{
						eleSetColor	= 2;
						eleName		= element_name;
						eleError 	= eleError+'<br>Please select '+element_value;
					}
					cntColorEx = 0;
				
				}
				else
				{
					cntColorEx = 1;
					//break;				
				}
			}
			else
			{
				cntColorNE	= 1;	
			}				
			
		} // for 
	} // if flag 

		//alert("eleError: "+eleError+" chkCnt : "+chkCnt+" validCntNew "+validCntNew);
		
		if(eleError != "" || chkCnt > 0 || validCntNew <= 0)
		{
			if(flag ==1)
			{
			  document.getElementById('errExvar').innerHTML = eleError;
			}
			return false;
		}
		else
		{
			//alert(1);
			document.frmProduct.submit();
		}
<!-------------------------------------------->
}
