function chk_login()
{
	var cond=true;
	if (document.form.txteadd.value.length==0){
		alert("Please enter email address.");
		if(cond==true){
		document.form.txteadd.focus();
		}
		cond=false;
		return false;
	}
	else if(!checkMail(document.form.txteadd.value)){
		alert("Email must contain an email address.");
		if(cond==true){
			document.form.txteadd.focus();
		}
		cond=false;
		return false;
	}	
	if (document.form.txtpass.value.length==0){
		alert("Please enter password.");
		if(cond==true){
		document.form.txtpass.focus();
		}
		cond=false;
		return false;
	}
}
function chk_fpass()
{
	var cond=true;
	if (document.form.txteadd.value.length==0){
		alert("Please enter email address.");
		if(cond==true){
		document.form.txteadd.focus();
		}
		cond=false;
		return false;
	}
	else if(!checkMail(document.form.txteadd.value)){
		alert("Email must contain an email address.");
		if(cond==true){
			document.form.txteadd.focus();
		}
		cond=false;
		return false;
	}	
}
function chk_contactus()
{
	var cond=true;
	if (document.form.txtname.value.length==0){
		alert("Please enter name.");
		if(cond==true){
		document.form.txtname.focus();
		}
		cond=false;
		return false;
	}
	if (document.form.txtemail.value.length==0){
		alert("Please enter email address.");
		if(cond==true){
		document.form.txtemail.focus();
		}
		cond=false;
		return false;
	}
	else if(!checkMail(document.form.txtemail.value)){
		alert("Email must contain an email address.");
		if(cond==true){
			document.form.txtemail.focus();
		}
		cond=false;
		return false;
	}	
	if (document.form.txtsub.value.length==0){
		alert("Please enter subject.");
		if(cond==true){
		document.form.txtsub.focus();
		}
		cond=false;
		return false;
	}
	if (document.form.txtmsg.value.length==0){
		alert("Please enter message.");
		if(cond==true){
		document.form.txtmsg.focus();
		}
		cond=false;
		return false;
	}	
}
function chk_register()
{
	var cond=true;
	if (document.form.txteadd.value.length==0){
		alert("Please enter email address.");
		if(cond==true){
		document.form.txteadd.focus();
		}
		cond=false;
		return false;
	}
	else if(!checkMail(document.form.txteadd.value)){
		alert("Email must contain an email address.");
		if(cond==true){
			document.form.txteadd.focus();
		}
		cond=false;
		return false;
	}	
	if (document.form.txteadd2.value.length==0){
		alert("Please enter confirm email address.");
		if(cond==true){
		document.form.txteadd2.focus();
		}
		cond=false;
		return false;
	}
	else if(!checkMail(document.form.txteadd2.value)){
		alert("Email must contain an email address.");
		if(cond==true){
			document.form.txteadd2.focus();
		}
		cond=false;
		return false;
	}	
	if(document.form.txteadd.value !== document.form.txteadd2.value)
	{
		alert("Email and Confirmed Email both should be same.");
		if(cond==true){
		document.form.txteadd2.focus();
		}
		cond=false;
		return false;
	}
	if (document.form.txtpass.value.length==0){
		alert("Please enter password.");
		if(cond==true){
		document.form.txtpass.focus();
		}
		cond=false;
		return false;
	}
	if (document.form.txtpass2.value.length==0){
		alert("Please enter confirm password.");
		if(cond==true){
		document.form.txtpass2.focus();
		}
		cond=false;
		return false;
	}
	if(document.form.txtpass.value !== document.form.txtpass2.value)
	{
		alert("Password and Confirmed Password both should be same.");
		if(cond==true){
		document.form.txtpass2.focus();
		}
		cond=false;
		return false;
	}
	if (document.form.txtfname.value == ""){
		alert("Please enter first name.");
		if(cond==true){
		document.form.txtfname.value="";
		document.form.txtfname.focus();
		}
		cond=false;
		return false;
	}	
}

function chk_placeorder()
{
	var cond=true;	
	if (document.form.cardno.value.length==0){
		alert("Please enter Card Number.");
		if(cond==true){
		document.form.cardno.focus();
		}
		cond=false;
		return false;
	}
	if(!IsNumeric(document.form.cardno.value))
	{
		alert("Please enter numeric value for Card Number.");
		if(cond==true)
		{
			document.form.cardno.value="";
			document.form.cardno.focus();
		}
		cond=false;
		return false;
	}
	if (document.form.selectmonth.value=='mm'){
		alert("Please Select Expire Month of Card.");
		if(cond==true){
		document.form.selectmonth.focus();
		}
		cond=false;
		return false;
	}	
	if (document.form.selectyear.value=='yy'){
		alert("Please Select Expire Year of Card.");
		if(cond==true){
		document.form.selectyear.focus();
		}
		cond=false;
		return false;
	}	
	if (document.form.cardcodeno.value.length==0){
		alert("Please Enter Security Number.");
		if(cond==true){
		document.form.cardcodeno.focus();
		}
		cond=false;
		return false;
	}	
	if(!IsNumeric(document.form.cardcodeno.value))
	{
		alert("Please enter numeric value for Security Number.");
		if(cond==true)
		{
			document.form.cardcodeno.value="";	
			document.form.cardcodeno.focus();
		}
		cond=false;
		return false;
	}
}

function chk_chk()
{
	var cond=true;
	if (document.form.sel_met.value=="ssm"){
		alert("Please Select Material.");
		if(cond==true){
		document.form.sel_met.focus();
		}
		cond=false;
		return false;
	}
/*	if (document.form.sel_size.value=="ssz"){
		alert("Please Select Size.");
		if(cond==true){
		document.form.sel_size.focus();
		}
		cond=false;
		return false;
	}
*/	if(!IsNumeric(document.form.txtgment.value))
	{
		alert("Please enter numeric value for grommets.");
		if(cond==true)
		{
			document.form.txtgment.value="";	
			document.form.txtgment.focus();
		}
		cond=false;
		return false;
	}
	if(!IsNumeric(document.form.txtqty.value))
	{
		alert("Please enter numeric value for quentity.");
		if(cond==true)
		{
			document.form.txtqty.value="";	
			document.form.txtqty.focus();
		}
		cond=false;
		return false;
	}
}


function checkMail(email){
var x = email;
var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (filter.test(x)){
	return true;
	}
	else {
	  return false;
	}
}
//  only insert integer no in Age field.
function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}
function addEvent(obj ,evt, fnc)
      {
        if (obj.addEventListener)
          obj.addEventListener(evt,fnc,false);
        else if (obj.attachEvent)
          obj.attachEvent('on'+evt,fnc);
        else
          return false;
        return true;
      }

function removeEvent(obj ,evt, fnc)
      {
        if (obj.removeEventListener)
          obj.removeEventListener(evt,fnc,false);
        else if (obj.detachEvent)
          obj.detachEvent('on'+evt,fnc);
        else
          return false;
        return true;
      }

      //----------

function appendElement(node,tag,id,htm)
      {
        var ne = document.createElement(tag);
        if(id) ne.id = id;
        if(htm) ne.innerHTML = htm;
        node.appendChild(ne);
      }
function getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    return cursor;
}

      //----------

function showPopup(p,pic,text)
      {
        mpos = getPosition();
		greyout(true);
        document.images.popImage.src = pic;
        document.getElementById(p).style.display = 'block';
		posX = (document.documentElement.clientWidth/2) - (document.getElementById(p).offsetWidth/2);
		//posY = mpos.y - (document.getElementById(p).offsetHeight/2);
		//scrolPosY = mpos.y - (document.documentElement.clientHeight/2);
		posY = (document.body.parentElement.scrollTop) + (document.documentElement.clientHeight/2) - (document.getElementById(p).offsetHeight/2);
		if(posY<101) posY = 101;
		document.getElementById(p).style.top = posY;
		document.getElementById(p).style.left = posX;
        picDis = document.getElementById('picDesc');
        if(picDis){
            picDis.innerHTML = text;
        }
		//document.body.parentElement.scrollTop = scrolPosY;
      }

function hidePopup(p)
      {
        greyout(false);
        document.images.popImage.src = 'images/loading.gif';
        document.getElementById(p).style.display = 'none';
      }

      //----------

function greyout(d,z)
      {
        var obj = document.getElementById('greyout');
        if(!obj)
        {
          appendElement(document.body,'div','greyout');
          obj = document.getElementById('greyout');
          obj.style.position = 'absolute';
          obj.style.top = '0px';
          obj.style.left = '0px';
          obj.style.background = '#111';
          obj.style.opacity = '.5';
          obj.style.filter = 'alpha(opacity=50)';
        }
        if(d)
        {
          if(!z){ z = -50 }
          obj.style.zIndex = z;
          obj.style.height = Math.max(document.body.scrollHeight,document.body.clientHeight)+'px';
          obj.style.width  = Math.max(document.body.scrollWidth,document.body.clientWidth)+'px';
          obj.style.display = 'block';
          addEvent(window,'resize',greyoutResize);
        }
        else
        {
          obj.style.display = 'none';    
          removeEvent(window,'resize',greyoutResize);
        }
      }
      
function greyoutResize()
      {
        var obj = document.getElementById('greyout');
        obj.style.height = document.body.clientHeight+'px';
        obj.style.width  = document.body.clientWidth+'px';
        obj.style.height = Math.max(document.body.scrollHeight,document.body.clientHeight)+'px';
        obj.style.width  = Math.max(document.body.scrollWidth,document.body.clientWidth)+'px';
      }

      //----------