// JavaScript Document

function checkProduct(){
	if(document.getElementById('product').value=='What are you looking for?'){ 
		return false; 
	}else {return true;}
}

// Pre-loading mouse hover background images
function preloadImages() {
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

<!--
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];}
}

// Return Object
function $(obj){
	return document.getElementById(obj);
}

function setDefaultEmail(){
	$('email').value='username@ispname.com';
}

// Reset Default Value to type
function resetVal(obj){
	var val=$(obj).value;
	if(val!='username@ispname.com')
	{
		$(obj).value=val;
	}else{
		$(obj).value='';
	}
}

// Check If Default Value Exists
function chkDefVal(obj){
	var val=$(obj).value;
	if(val=='username@ispname.com' || val=='')
	{
		$(obj).value='username@ispname.com';
	}else{
		$(obj).value=val;
	}
}

// Check Valid Email
function checkEmail(email) {
	email=document.getElementById('email');
	if (email)	{
		var e=email.value;
		//var e = $(email).value;
		//email.value = e.trim();
		email.value=e;
		if(email.value=='username@ispname.com'){
			return false;
		}else{
			var filter = /^[A-Za-z0-9][A-Za-z0-9\_\-\.]*\@[A-Za-z0-9][A-Za-z0-9\_\-\.]*\.[A-Za-z]{2,}$/;
			var filter2 = /(\.\.+)|(\@\@+)|(\_\_+)|(\-\-+)/;
			var filter3 = /(\.ac|\.ad|\.ae|\.aero|\.af|\.ag|\.ai|\.al|\.am|\.an|\.ao|\.aq|\.ar|\.arpa|\.as|\.at|\.au|\.aw|\.ax|\.az|\.ba|\.bb|\.bd|\.be|\.bf|\.bg|\.bh|\.bi|\.biz|\.bj|\.bm|\.bn|\.bo|\.br|\.bs|\.bt|\.bv|\.bw|\.by|\.bz|\.ca|\.cat|\.cc|\.cd|\.cf|\.cg|\.ch|\.ci|\.ck|\.cl|\.cm|\.cn|\.co|\.com|\.coop|\.cr|\.cu|\.cv|\.cx|\.cy|\.cz|\.de|\.dj|\.dk|\.dm|\.do|\.dz|\.ec|\.edu|\.ee|\.eg|\.er|\.es|\.et|\.eu|\.fi|\.fj|\.fk|\.fm|\.fo|\.fr|\.ga|\.gb|\.gd|\.ge|\.gf|\.gg|\.gh|\.gi|\.gl|\.gm|\.gn|\.gov|\.gp|\.gq|\.gr|\.gs|\.gt|\.gu|\.gw|\.gy|\.hk|\.hm|\.hn|\.hr|\.ht|\.hu|\.id|\.ie|\.il|\.im|\.in|\.info|\.int|\.io|\.iq|\.ir|\.is|\.it|\.je|\.jm|\.jo|\.jobs|\.jp|\.ke|\.kg|\.kh|\.ki|\.km|\.kn|\.kr|\.kw|\.ky|\.kz|\.la|\.lb|\.lc|\.li|\.lk|\.lr|\.ls|\.lt|\.lu|\.lv|\.ly|\.ma|\.mc|\.md|\.mg|\.mh|\.mil|\.mk|\.ml|\.mm|\.mn|\.mo|\.mobi|\.mp|\.mq|\.mr|\.ms|\.mt|\.mu|\.museum|\.mv|\.mw|\.mx|\.my|\.mz|\.na|\.name|\.nc|\.ne|\.net|\.nf|\.ng|\.ni|\.nl|\.no|\.np|\.nr|\.nu|\.nz|\.om|\.org|\.pa|\.pe|\.pf|\.pg|\.ph|\.pk|\.pl|\.pm|\.pn|\.pr|\.pro|\.ps|\.pt|\.pw|\.py|\.qa|\.re|\.ro|\.ru|\.rw|\.sa|\.sb|\.sc|\.sd|\.se|\.sg|\.sh|\.si|\.sj|\.sk|\.sl|\.sm|\.sn|\.so|\.sr|\.st|\.su|\.sv|\.sy|\.sz|\.tc|\.td|\.tel|\.tf|\.tg|\.th|\.tj|\.tk|\.tl|\.tm|\.tn|\.to|\.tp|\.tr|\.travel|\.tt|\.tv|\.tw|\.tz|\.ua|\.ug|\.uk|\.um|\.us|\.uy|\.uz|\.va|\.vc|\.ve|\.vg|\.vi|\.vn|\.vu|\.wf|\.ws|\.ye|\.yt|\.yu|\.za|\.zm|\.zw)$/i;
	
			if( (!filter.test( email.value ))  || ( filter2.test( email.value )) || ( !filter3.test( email.value )) ) {
				return false;
			}
		}
	}
	return true;
}

// Do Validation
function validateSignUpForm(){
	if(checkEmail('email')){
		return true;		  
	}else{
		$('statusInfo').innerHTML='<strong>Whoops. We didn\'t send an invitation to that address.<br />Please check that you\'ve entered it correctly.</strong>';	
		$('email').value=$('email').value;	
		return false;
	}
}

// Toggle Find Products
function toggleFind(){
	var state=document.getElementById('findbox').style.display;
	var ver=navigator.appVersion;
	var keyText='; MSIE ';
	var version=parseFloat(ver.substr(ver.indexOf(keyText)+keyText.length,3));
	if(state=='none'){
		document.getElementById('findbox').style.display='block';
		document.getElementById('findboxend').style.display='none';
		document.getElementById('maskboxend').style.position='relative';
		document.getElementById('maskboxend').style.margin='-24px -4px 0px 0px';
		if(navigator.appName=='Microsoft Internet Explorer' && version<=6.0){
			document.getElementById('maskboxend').style.left='0px';
			document.getElementById('maskboxend').style.margin='0px 0px 0px 0px';
		}
		if(navigator.appName=='Microsoft Internet Explorer' && version>=7.0){
			document.getElementById('maskboxend').style.left='0px';
			document.getElementById('maskboxend').style.margin='0px 0px 0px 0px';
		}
	}else{
		document.getElementById('findbox').style.display='none';
		document.getElementById('findboxend').style.display='block';
		if(navigator.appName=='Microsoft Internet Explorer' && version>=7.0){
		}
	}
}

// For Search Process 
function clearValue(obj)
{
	document.getElementById(obj.id).value='';
}
function searchDefault(){
	var val=document.getElementById('product').value;
	if(val=='What are you looking for?' || val=='')
	{
		document.getElementById('product').value='What are you looking for?';
	}else{
		document.getElementById('product').value=val;
	}
}
function doFind_keydown(e,skey)
{
	var keynum;
	var keychar;

	if(window.event) // IE
		keynum = e.keyCode;
	else if(e.which) // Netscape/Firefox/Opera
		keynum = e.which;
	keychar = String.fromCharCode(keynum);
	
	if(keynum==13)
	{	
		//alert(skey);
		value=document.getElementById("product").value;
		var searchUrl='https://www.thefind.com/search?query='+value+'&cobrand=paypalus';
		document.getElementById('searchframe').src=searchUrl;
	}
}
function finder(){
	// For Search
	var skey=window.location.search.substring(1);
	var key_result=skey.split("=");
	var keyUrl='https://www.thefind.com/search?query='+key_result[1]+'&cobrand=paypalus';
	document.getElementById('searchframe').src=keyUrl;
}

// Get Details
function showDetails(eid,type){
	var ver=navigator.appVersion;
	//alert(ver);
	var keyText='; MSIE ';
	var version=parseFloat(ver.substr(ver.indexOf(keyText)+keyText.length,3));
	if(type=="left"){
		if(navigator.appName=='Microsoft Internet Explorer' && version<=6.0){
			document.getElementById(eid).style.margin='-50px 0px 0px 50px';
		}else if(navigator.appName=='Microsoft Internet Explorer' && version==7.0){
			document.getElementById(eid).style.margin='-50px 0px 0px 50px';
		//}//else if(navigator.appName=='Microsoft Internet Explorer' && version==8.0){
		//	document.getElementById(eid).style.margin='-150px 0px 0px 130px';
		}else{
			document.getElementById(eid).style.margin='-50px 0px 0px 130px';
		}
	}else{
		if(navigator.appName=='Microsoft Internet Explorer' && version<=6.0){
			document.getElementById(eid).style.margin='-50px 0px 0px -525px';
		}else if(navigator.appName=='Microsoft Internet Explorer' && version==7.0){
			document.getElementById(eid).style.margin='-50px 0px 0px -525px';
		}else{
			document.getElementById(eid).style.margin='-50px 0px 0px -445px';
			document.getElementById(eid).style.width="480px";
			document.getElementById(eid).style.height="231px";
		}
	}
	document.getElementById(eid).style.display='block';
	document.getElementById(eid).style.position='absolute';
}

function showDetails_small(eid,type){
	var ver=navigator.appVersion;
	//alert(ver);
	var keyText='; MSIE ';
	var version=parseFloat(ver.substr(ver.indexOf(keyText)+keyText.length,3));
	if(type=="left"){
		if(navigator.appName=='Microsoft Internet Explorer' && version<=6.0){
			document.getElementById(eid).style.margin='-50px 0px 0px -60px';
		}else if(navigator.appName=='Microsoft Internet Explorer' && version==7.0){
			document.getElementById(eid).style.margin='-50px 0px 0px -50px';
		//}//else if(navigator.appName=='Microsoft Internet Explorer' && version==8.0){
		//	document.getElementById(eid).style.margin='-150px 0px 0px 130px';
		}else{
			document.getElementById(eid).style.margin='-50px 0px 0px 130px';
		}
	}else{
		if(navigator.appName=='Microsoft Internet Explorer' && version<=6.0){
			document.getElementById(eid).style.margin='-50px 0px 0px -425px';
		}else if(navigator.appName=='Microsoft Internet Explorer' && version==7.0){
			document.getElementById(eid).style.margin='-50px 0px 0px -425px';
		}else{
			document.getElementById(eid).style.margin='-50px 0px 0px -220px';
			document.getElementById(eid).style.width="277px";
			document.getElementById(eid).style.height="231px";
		}
	}
	//document.getElementById(eid).style.border='1px red solid';
	document.getElementById(eid).style.display='block';
	document.getElementById(eid).style.position='absolute';
}


function hideDetails(eid){
	document.getElementById(eid).style.display='none';
	//alert(eid);
}

function showElement(id){
	document.getElementById(id).style.display="block";
}
function hideElement(id){
	document.getElementById(id).style.display="none";
}
function FF3_formdivfix(){
	var ver=navigator.userAgent;
	var keyText='Firefox/';
	var version=ver.substr(ver.indexOf(keyText));
	var ffv=version.split('/');
	var ffversion=parseFloat(ffv[1]);
	
	if(navigator.appName=='Netscape' && ffversion>3){
		document.getElementById('formdivclass').style.position='relative';
		document.getElementById('formdivclass').style.top='-2px';
		document.getElementById('formdivclass').style.right='-5px';
		document.getElementById('maskboxend').style.left='-4px';
		document.getElementById('formdivclass').style.margin='0px -1px 0px 0px';
	}else if(navigator.appName=='Netscape' && ffversion<3){
		document.getElementById('maskboxend').style.left='-1px';
	}else if(navigator.appName=='Netscape' && ffversion==3){
		document.getElementById('formdivclass').style.position='relative';
		document.getElementById('formdivclass').style.top='-2px';
		document.getElementById('formdivclass').style.right='-10px';
		document.getElementById('formdivclass').style.margin='0px -5px 0px 0px';
		document.getElementById('maskboxend').style.left='0px';
	}else{
		document.getElementById('formdivclass').style.position='relative';
		document.getElementById('formdivclass').style.top='-2px';
		document.getElementById('formdivclass').style.right='-5px';
		document.getElementById('maskboxend').style.left='-4px';
		document.getElementById('formdivclass').style.margin='0px -1px 0px 0px';
	}
	
	var ieVer=navigator.appVersion;
	var keyText='; MSIE ';
	var ieVersion=parseFloat(ieVer.substr(ieVer.indexOf(keyText)+keyText.length,3));
	if(navigator.appName=='Microsoft Internet Explorer' && ieVersion>7){
		document.getElementById('formdivclass').style.position='relative';
		document.getElementById('formdivclass').style.top='-2px';
		document.getElementById('formdivclass').style.right='-5px';
		document.getElementById('maskboxend').style.left='-4px';
		document.getElementById('formdivclass').style.margin='0px -5px 0px 0px';
	}
}


