//ajax newsletter validation 
// other validation and pop up functions
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 = "http://www.kreditkarte.com/";
	var who = "Kreditkarte.com – der unabhängige Ratgeber";

	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 Bookmark Us!";
		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()
{
	if(document.frmNews.txtName_S.value == "")
	{
		alert("Please Enter Name");	
		document.frmNews.txtName_S.focus();	
		return false;
	}		

	if(document.frmNews.txtEmail_S.value == "")
	{
		alert("Please Enter Email");			
		document.frmNews.txtEmail_S.focus();	
		return false;
	}
	else
	{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.frmNews.txtEmail_S.value))
		{
			return true;
		}
		else
		{
			alert("Invalid E-mail Address! Please re-enter.")
			return false;
		}
	}
	return true;
}

function popImage(imageURL,imageTitle){
	PositionX = 10;
	PositionY = 10;
	defaultWidth = 400;
	defaultHeight = 400;
	var AutoClose = true;
	var imgWin = window.open('','_blank','scrollbars=no,resizable=1 ,width='+defaultWidth+',height='+defaultHeight+',l eft='+PositionX+',top='+PositionY);
	if( !imgWin ) { return true; } //popup blockers should not cause errors
	imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><script type="text\/javascript">\n'+
	'function resizeWinTo() {\n'+
	'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
	'var oH = document.images[0].height, oW = document.images[0].width;\n'+
	'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
	'window.doneAlready = true;\n'+ //for Safari and Opera
	'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
	'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
	'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
	'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
	'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
	'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
	'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
	'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
	'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
	'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
	'}\n'+
	'<\/script>'+
	'<\/head><body onload="resizeWinTo();"'+(AutoClose?' onblur="self.close();"':'')+'>'+
	(document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;display:table;">'))+
	'<img src='+imageURL+' alt="Loading image ..." title="" onload="resizeWinTo();">'+
	(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
	imgWin.document.close();
	if( imgWin.focus ) { imgWin.focus(); }
	return false;
}

/******* Compare Product Functions *******/
function frmSubmit(curPID,aID)
{	
	document.frmcompare.txtPID.value = curPID;
	if(aID == 1)
	{
		document.frmcompare.action='index.php';
	}
	else
	if(aID == 2)
	{
		document.frmcompare.action='Products.php';	
	}
	document.frmcompare.submit();
}

function handleHttpResponseCompL()
    {   
		if (http.readyState == 4) 
		{
			  if(http.status==200) 
			  {
				var results=http.responseText;
				//alert(results);
				if(results == 0)
				{
					document.getElementById('openingboxleftCompl').innerHTML = "Please select any of the product to compare";
				}
				else
				{
					document.frmcompare.submit();
				}
				
			  }
		   
		 }
   }
   
function checkComparePrd(stURL) 
{   
	var total=0;
	var comp = document.frmcompare['compare1[]'];	
	var compproductList = document.frmcompare['txtProductList'].value;	
	//alert(compproductList);
	if(comp.length>0)
	{
		for(var i=0; i < comp.length; i++)
		{
			if(comp[i].checked)
			total = total + 1;
		}
	}
	var urlComp = stURL+"/validationCompare.php?checkvalue="+ total + "&compList='"+compproductList+"'"; // The server-side script	
	http.open("GET", urlComp, true);
	http.onreadystatechange = handleHttpResponseCompL;
	http.send(null);
}
	
	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();

/********* Compare PRoduct Function ends here *********/
function EmptyValues()
	{
	  docum = document.frmDisplay;
	  if(docum.chkEmpty.checked==true)
	  {
		docum.Fname.value 		= "";//first name
		docum.Lname.value 		= "";//lastname
		docum.address.value 	= "";//address
		docum.county.value		= "";//state
		docum.postcode.value 	= "";//city		
	  }
	}
	
	
function addToCart(stURLCart,tmpProductId,tmpProdPrice,tmpProdColor,tmpProdDisc)
{
		//alert(1);
		var tmpPId		= tmpProductId;
		var tmpPriceId	= tmpProdPrice;
		var tmpColorId	= tmpProdColor;
		var tmpDisc		= tmpProdDisc;
		
		window.location.href = stURLCart+"/shopping-cart/addtocart.php?prodId="+tmpPId+"&price="+tmpPriceId+"&color="+tmpColorId+"&discount="+tmpDisc;
}
/*********  Ebook Sale Process Functions *********/
function popup(url)
{	
	var winpopup;
	if(winpopup)
	{
		winpopup.close();
	}
	winpopup=window.open(url,'winpopup','height=500,width=600,left=150,top=100,resizable=yes,scrollbars=yes,toolbar=no,status=yes');
}


function EbookSumbitt()
{
	document.frmProduct.action = "ebook_order_detail.php";
	document.frmProduct.submit();
}
function product_check(objProduct)
{
	var obProductList;
	var objProductVal	= objProduct.value;
	var objProductCheck	= objProduct.checked;
	obProductList	= document.getElementById("txtProductList").value;
	if(objProductCheck	== true)
	{
		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;
	}	
}

function PrintPage()
{
	window.print();	
	return false;
}