
function isDate(Dt)
{
  if(isNaN(Dt.substr(0,4)-0)||!(Dt.substr(5,2)-0)||(Dt.substr(5,2)-0>12)||isNaN(Dt.substr(5,2)-0)||!(Dt.substr(8,2)-0)||(Dt.substr(8,2)-0>31)||isNaN(Dt.substr(8,2)-0)||(Dt.substr(8,2)-0>30 && (Dt.substr(5,2)-0==4 || Dt.substr(5,2)-0==6 || Dt.substr(5,2)-0==9 ||Dt.substr(5,2)-0==11))||(Dt.substr(5,2)-0==2 && (Dt.substr(0,4)-0)%4==0 && Dt.substr(8,2)-0>29)||(Dt.substr(5,2)-0==2 && (Dt.substr(0,4)-0)%4!=0 && Dt.substr(8,2)-0>28)||Dt.substr(4,1)!="-"||Dt.substr(7,1)!="-")
  {
      return false;
  }
  else
  {
      return true
  }
}

function doBlink() {
  var blink = document.all.tags("BLINK")
  for (var i=0; i < blink.length; i++)
    blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function startBlink() {
  if (document.all)
    setInterval("doBlink()",1000)
}
window.onload = startBlink;


function isEmail(Ml)
{
  if(!Ml){return true}
  if(Ml.indexOf("@")<=0 || Ml.indexOf("@")==Ml.length-1 || Ml.indexOf(".")<=0 || Ml.indexOf(".")==Ml.length-1 || Ml.indexOf("..")!=-1 || Ml.indexOf("@@")!=-1 || Ml.indexOf("@.")!=-1 || Ml.indexOf(".@")!=-1)
  {
      return false
  }
  else
  {
      return true
  }
}

function Trim (s){return LTrim(RTrim(' '+s));}
function LTrim (s)
{
    if(!s){return '';}
    while(s.charAt(0)==' ')
        s = s.substring(1,s.length);
    return s;
}
//..............

function RTrim (s)
{
    if(!s || s==' '){return '';}
    if (s.length > 1)
    {
        while(s.charAt(s.length-1)==' ')
            s = s.substring(0,s.length-2);
        return s;
    }
}


function sort(x,y)
{
 var frm=document.forms['search'];
 frm.sort.value=x;
 frm.type.value=y;
 frm.search.value=1;
 frm.submit();
}
function dateString(oneDate) 
{
	var theDay = dayNames[oneDate.getDay() + 1]
	var theMonth = monthNames[oneDate.getMonth() + 1]
	var theYear = oneDate.getFullYear()
	return theDay +" "+ theMonth + " " + oneDate.getDate() + ", " + theYear
}

function ValidSet(frm)
{
	var txt="";
   
    if(!frm.site_title.value)
	{   
	   txt+="     Site Title should not be blank.\n";
	}
	if(!frm.admin_mail.value)
	{
	   txt+="     Admin Email Address should not be blank.\n";
	}
	if(!frm.meta_keys.value) 
	{
	   txt+="     Meta Keys should not be blank.\n";
	}
	if(!frm.meta_desc.value) 
	{
	   txt+="     Meta Description should not be blank.\n";
 	}
	if(txt)
	{
   	  alert("Sorry!! Following errors has been occured :\n\n"+ txt +"\n     Please Check");
  	  return false
	}
    return true	
}

function ValidCon(frm)
{
    var txt="";
	
	if(!frm.name.value)
	{
		txt+="     Name should not be empty.\n"
	}
	if(!frm.email.value || !isEmail(frm.email.value))
	{
	   txt+="     Enter valid Email Address.\n"
       
 	}
	if(!frm.section.value)
	{
		txt+="     Section should not be empty.\n"
	}
	if(!frm.subject.value)
	{
		txt+="     Title of Email should not be empty.\n"
	}
	if(!frm.description.value)
	{
		txt+="     You did not put any Comments.\n"
	}  
   	if(txt)
	{
   		alert("Sorry!! Following errors has been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	
}
function ValidPass(frm)
{
    var txt="";   
    if(!frm.pass.value || frm.pass.value.length<4) 
	{
	   txt+="     Password should not be blank or password less than 4 chars.\n"
	}	
 	if(txt)
	{
   		alert("Sorry!! Following errors has been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}
function ValidCat(frm)
{
    var txt="";   
    if(!frm.cat_name.value) 
	{
	   txt+="     Category Name should not be blank.\n"
	}	
 	if(txt)
	{
   		alert("Sorry!! Following errors has been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}
function ValidSubcat(frm)
{
    var txt="";   
    if(!frm.sub_cat_name.value) 
	{
	   txt+="     Sub Category Name Name should not be blank.\n"
	}	
 	if(txt)
	{
   		alert("Sorry!! Following errors has been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}
function ValidEditor(frm)
{
    var txt="";   
    if(!frm.cont_title.value) 
	{
	   txt+="     Title should not be blank.\n"
	}	
 	if(txt)
	{
   		alert("Sorry!! Following errors has been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}
function ValidFpass(frm)
{
    var txt="";   
	
    if(!Trim(frm.admin_mail.value) || !isEmail(frm.admin_mail.value))
	{
	   txt+="     Enter valid email address\n"
       
 	}
 	if(txt)
	{
   		alert("Sorry!! Following errors has been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}
function ValidAlogin(frm)
{
    var txt="";   
	
	if(!frm.username.value)
	{
	   txt+="     Username should not be blank.\n"
       
 	}
	
    if(!frm.password.value)
	{
	   txt+="     Password should not be blank.\n"
       
 	}
 	if(txt)
	{
   		alert("Sorry!! Following errors has been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}

function isValidNumber(inpString) {
   return /^[-+]?\d+(\.\d+)?$/.test(inpString);
}

function ValidCart(frm)
{
	var txt="";
   
    if((!frm.qty.value) || !isValidNumber(frm.qty.value) || (frm.qty.value =="0"))
	{   
	   txt+="     Qty should not be empty.\n";
	}			
	if(txt)
	{
   	  alert("Sorry. The following errors have been occured :\n\n"+ txt +"\n     Please Check");
  	  return false
	}
    return true	
}

function CheckForms(frm)
{
	var txt="";
	if(!frm.card_holder_name.value)
	{
		txt+="     Card Holder Name should not be empty\n"
	}
	if(!frm.card_number.value)
	{
		txt+="     Credit Card Number should not be empty\n"
	}
	if(!frm.card_code.value)
	{
		txt+="     Credit Card Code should not be empty\n"
	}
	if(!frm.ship_first_name.value)
	{
		txt+="     First Name should not be empty\n"
	}
    if(!frm.ship_last_name.value)
	{
		txt+="     Last Name should not be empty\n"
	}
	
	if(!frm.ship_email.value || !isEmail(frm.ship_email.value))
	{
		txt+="     Invalid Email Id\n";
	}
	
    if(frm.ship_phone_number.value=="")
    {
		txt+="     You did not put any phone number \n"
	}  
    
	if(frm.ship_address.value=="")
	{
		txt+="     Address should not be empty \n"
	}
	if(frm.ship_city.value=="")
	{
		txt+="     City should not be empty \n"
	}
    
	if(frm.ship_postal_code.value=="")
	{
		txt+="     Postal Code should not be empty\n"
	}
	if(!frm.terms_condition.checked)
	{
		txt+="     Please Check the checkbox to indicate that you agreed terms and conditions.\n"
	}	
    
   	if(txt)
	{
   		alert("Sorry. The following errors have been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	
}

function ValidContactus(frm)
{
	var txt="";
	if(!frm.fname.value)
	{
		txt+="First Name should not be empty.\n"
	}
	if(!frm.lname.value)
	{
		txt+="Last Name should not be empty.\n"
	}
	
	if(!frm.email.value || !isEmail(frm.email.value))
	{
	   txt+="Enter valid email address.\n"
       
 	}
	
	if(!frm.message.value)
	{
		txt+="Please Enter Message.\n"
	}
	
	
	if(txt)
	{
		alert("Sorry. You left some mandatory fields :\n\n"+ txt +"\nPlease Check");
		return false
	}
return true	
}

function checkreg(frm)
{
	var txt="";
   
	   if(!frm.fname.value) 
	   {
		   txt+="First Name should not be blank.\n";
	   }
	   if(!frm.lname.value) 
	   {
		   	txt+="Last Name should not be blank.\n";
	   }	   
	   if(!frm.email.value || !isEmail(frm.email.value))
	   {
	    	txt+="Enter valid email address.\n"       
 	   }	   
	   if(!frm.address.value) 
	   {
		   txt+="Address should not be blank.\n";
 	   }		 
	   if(!frm.zip.value)
	   {   
		   txt+="Zip should not be blank.\n";
	   }
	   if(!frm.city.value)
	   {   
		   txt+="City should not be blank.\n";
	   }	   
	  
	   if(!frm.state.value)
	   {   
		   txt+="Please enter your state name.\n";
	   }
	   
	   if(!frm.country.value)
	   {   
		   txt+="Please select your country.\n";
	   }
	   
	   if(!frm.password.value)
	   {   
		   txt+="Password should not be blank.\n";
	   }	    
	   if(!frm.condition1.checked)
	   {   
		   txt+="You did not agree with our Terms and Conditions.\n";
	   }
	  
 	   if(txt)
	   {
   		  	alert("Sorry. The following errors have occurred :\n\n"+ txt +"\nPlease Check");
  	 	  	return false
	   }
       return true	
}