function FP_swapImg() {//v1.0
 var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
 n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
 elm.$src=elm.src; elm.src=args[n+1]; } }
}

function FP_preloadImgs() {//v1.0
 var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
 for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}

function FP_getObjectByID(id,o) {//v1.0
 var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
 else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
 if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
 for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
 f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
 for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
 return null;
}

function validateEmail(fld)
{
	var my=fld.value;
	var attherate=my.indexOf("@");
	var lastattherate = my.lastIndexOf("@")
	var dotpos=my.lastIndexOf(".");
	var posspace = my.indexOf(" ");
	var totallen = my.length;
	
	if (attherate<=0 || dotpos<=0 || attherate > dotpos || (dotpos-attherate)<=1 || (dotpos == totallen-1) || posspace > -1 || attherate!=lastattherate)
		return false;
	else
		return true;
}

function validateInquiryForm(frm)
{
	if(frm.name.value.split(" ").join("") == "")
	{
		alert('Name can not be blank !!');
		frm.name.focus();
		return false;
	}
	if(frm.companyname.value.split(" ").join("") == "")
	{
		alert('Company Name can not be blank !!');
		frm.companyname.focus();
		return false;
	}
	if(frm.address.value.split(" ").join("") == "")
	{
		alert('Address can not be blank !!');
		frm.address.focus();
		return false;
	}
	if(frm.city.value.split(" ").join("") == "")
	{
		alert('City can not be blank !!');
		frm.city.focus();
		return false;
	}
	if(frm.country.value.split(" ").join("") == "")
	{
		alert('Country can not be blank !!');
		frm.country.focus();
		return false;
	}
	if(frm.phone.value.split(" ").join("") == "")
	{
		alert('Phone can not be blank !!');
		frm.phone.focus();
		return false;
	}
	if(frm.email.value.split(" ").join("") == "")
	{
		alert('Email can not be blank !!');
		frm.email.focus();
		return false;
	}
	if(!validateEmail(frm.email))
	{
		alert('Invalide Email !!');
		frm.email.focus();
		return false;
	}
	if(frm.subject.value.split(" ").join("") == "")
	{
		alert('Subject can not be blank !!');
		frm.subject.focus();
		return false;
	}
	if(frm.productinquiry.value.split(" ").join("") == "")
	{
		alert('Product Inquiry can not be blank !!');
		frm.productinquiry.focus();
		return false;
	}
	if(frm.comment.value.split(" ").join("") == "")
	{
		alert('Comment can not be blank !!');
		frm.comment.focus();
		return false;
	}
}

var newwindow = ''
function popitup(url) {
	if (newwindow.location && !newwindow.closed) {
		newwindow.location.href = url;
		newwindow.focus(); }
	else {
		newwindow=window.open(url,'htmlname','width=800,height=600,resizable=1');}
}

