// JavaScript Document
function echeck(str) {
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID");
		   return false;
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID");
		   return false;
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID");
		    return false;
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
}
function validate_registration() {
	if ( document.regfrm.fname.value == '' ) {
		alert('Please Enter First Name!');	
		document.regfrm.fname.focus();
		return false;
	}
	if ( document.regfrm.lname.value == '' ) {
		alert('Please Enter Last Name!');	
		document.regfrm.lname.focus();
		return false;
	}
	var f = document.regfrm.email;
	if ( ( f.value == null ) || ( f.value == "" ) )	{
	    alert("Please Enter Email address!");
		f.focus();
		return false;
	}
	if ( echeck(f.value) == false )
	{
	    f.value = "";
		f.focus();
		return false;
	}
	if ( document.regfrm.password.value == '' ) {
		alert('Please Enter Password!');	
		document.regfrm.password.focus();
		return false;
	}
	if ( document.regfrm.country.value == '' ) {
		alert('Please select Country!');	
		document.regfrm.country.focus();
		return false;
	}
	if ( document.regfrm.confirmtext.value == '' ) {
		alert('Please Enter Text Shown in Image!');	
		document.regfrm.confirmtext.focus();
		return false;
	}
	if ( document.regfrm.terms.checked == false ) {
		alert('You must agree with terms and condition!');	
		return false;
	}
}

function validate_login(){
	var f = document.loginfrm.email;
	if ( ( f.value == null ) || ( f.value == "" ) )	{
	    alert("Please Enter Email address!");
		f.focus();
		return false;
	}
	if ( echeck(f.value) == false )
	{
	    f.value = "";
		f.focus();
		return false;
	}
	if ( document.loginfrm.password.value == '') {
		alert('Please Enter Password!');	
		document.loginfrm.password.focus();
		return false;
	}
}
function validate_forgot_password(){
	var f = document.forgot_password_frm.email;
	if ( ( f.value == null ) || ( f.value == "" ) )	{
	    alert("Please Enter Email address!");
		f.focus();
		return false;
	}
	if ( echeck(f.value) == false )
	{
	    f.value = "";
		f.focus();
		return false;
	}
}

function validate_change_password() {
	if ( document.change_password_frm.old_password.value == '') {
		alert('Please Enter Old Password!');	
		document.change_password_frm.old_password.focus();
		return false;
	}	
	if ( document.change_password_frm.new_password.value == '') {
		alert('Please Enter New Password!');	
		document.change_password_frm.new_password.focus();
		return false;
	}	
	if ( document.change_password_frm.cnew_password.value == '') {
		alert('Please Enter Confirm New Password!');	
		document.change_password_frm.cnew_password.focus();
		return false;
	}	
	if ( document.change_password_frm.cnew_password.value != document.change_password_frm.new_password.value) {
		alert('New Password and Confirm New Password!');	
		document.change_password_frm.cnew_password.focus();
		return false;
	}	
}

function validate_img_frm(){
	if ( document.upload_img_frm.category.value == '' ) {
		alert('Please Select Category!');
		document.upload_img_frm.category.focus();
		return false;
	}	
	if ( document.upload_img_frm.image.value == '' ) {
		alert('Please Select Image!');
		document.upload_img_frm.image.focus();
		return false;
	}	
	document.upload_img_frm.Submit.value = 'Uploading...';
	document.upload_img_frm.Submit.disabled = true;
/*	if ( isNaN(document.upload_img_frm.year.value) || document.upload_img_frm.year.value.length != 4  ) {
		alert('Invalid Year!');
		document.upload_img_frm.year.focus();
		return false;
	}	
	if ( isNaN(document.upload_img_frm.month.value) || document.upload_img_frm.month.value.length != 2  ) {
		alert('Invalid Month!');
		document.upload_img_frm.year.focus();
		return false;
	}	*/
}
function show_imgfrm() {
	document.getElementById("upimg").style.display = '';	
}
function checkAll()
{
	var rs = (document.mycartfrm.inboxAll.checked)?true:false;
	for(i=0;i<document.mycartfrm.elements.length;i++)
	{
	  	if(document.mycartfrm.elements[i].id == 'iId')
  		{
			document.mycartfrm.elements[i].checked = rs;
		}
	}  
}

