// JavaScript Document

/// VALIDATION FOR ADMIN INDEX USERNAME ,PASSWORD
function CheckAdminlogin(frm)  /// function  CheckAdminlogin START HERE
{

		if(!CheckEmpty(frm.username.value,"User Name"))
		{
			frm.username.focus();
			return false;
		}

		if(!CheckEmpty(frm.password.value,"Password"))
		{
			frm.password.focus();
			return false;
		}
} /// function  CheckAdminlogin END HERE

///Check oldpassword and given passsword is correct CheckPassword start here
function CheckPassword(frm)
{
		if(frm.oldpass.value=="")
		{
			alert("Old Password should not be empty");
			frm.oldpass.focus();
			return false;
		}
		if(frm.newpass.value=="")
		{
			alert("New Password should not be empty");
			frm.newpass.focus();
			return false;
		}
		if(frm.rnewpass.value=="")
		{
			alert("Please retype your Password");
			frm.rnewpass.focus();
			return false;
		}
		if(frm.newpass.value!=frm.rnewpass.value)
		{
			alert("Admin Password and Retype Password should be Equal");
			frm.rnewpass.focus();
			return false;
		}
}
//CheckPassword Close here

//-------------------------------------- Contact Page Validation Start Here --------------------------------------//
function CheckContact(frm)
{
	if(!CheckEmpty(frm.txtname.value,"Name"))
	{
		frm.txtname.value='';
		frm.txtname.focus();
		return false;
	}
	if(!CheckEmpty(frm.txtemail.value,"Email Address"))
	{
		frm.txtemail.value='';
		frm.txtemail.focus();
		return false;
	}
	if(!CheckEmailAddr(frm.txtemail.value,"Email Address"))
	{
		alert("Invalid Email Address");
		frm.txtemail.value='';
		frm.txtemail.focus();
		return false;
	}
}
//-------------------------------------- Contact Page Validation End Here --------------------------------------//

//------------------------------------ Blog Page Validateion Start Here------------------------------------------//

function CheckBlogData(frm)
{
	if(!CheckEmpty(frm.name.value,"Name"))
	{
		frm.name.value='';
		frm.name.focus();
		return false;
	}
	if(!CheckEmpty(frm.emailid.value,"Email Address"))
	{
		frm.emailid.focus();
		frm.emailid.value='';
		return false;
	}
	if(!CheckEmailAddr(frm.emailid.value,"Email"))
	{
		alert("Please Enter Valid Email Address");
		frm.emailid.focus();
		frm.emailid.value='';
		return false;
	}
	if(!CheckEmpty(frm.answer.value,"Comment"))
	{
		frm.answer.value='';
		frm.answer.focus();
		return false;
	}
}

//------------------------------------ Blog Page Validateion End Here------------------------------------------//

// ------------------------------------Catalog Validation Start Here  -------------------------------------------//

//Category Start
function CheckCatData(frm)
{
	if(!CheckEmpty(frm.category.value,"Corporate"))
	{
		frm.category.value='';
		
		frm.category.focus();
		return false;
	}
	if(!CheckEmpty(frm.user.value,"User name"))
	{
		frm.user.value='';
		
		frm.user.focus();
		return false;
	}
	if(!CheckEmpty(frm.pass.value,"Password"))
	{
		frm.pass.value='';
		
		frm.pass.focus();
		return false;
	}
	
	
}
//end of category function

//Sub Category Start
function CheckSubCatData(frm)
{
	if(frm.category.value==0)
	{
		alert("Please Select Category");
		frm.category.focus();
		return false;
	}
	if(!CheckEmpty(frm.subcategory.value,"Sub Category"))
	{
		frm.subcategory.value='';
		frm.subcategory.focus();
		return false;
	}
		
		/*if(frm.prodimg.value!='')
		{
		if(!ThumbnailEdit(frm.prodimg.value))
		{
		
		frm.prodimg.focus();
		return false;
		}
		}*/
	
}//end of sub category function
function ThumbnailEdit(what){    
//Thumbnail Image Validation

var image11 = document.frmadd.prodimg.value;
var imgtype11 = image11.indexOf('.',0);
var imgexten11=image11.substring(imgtype11+1,image11.length);
	if((imgexten11!='jpg') && (imgexten11!='JPG') && (imgexten11!='jpeg') && (imgexten11!='JPEG') && (imgexten11!='png') && (imgexten11!='PNG') )
	{
		alert("Please Select Valid JPG or JPEG or PNG Image File");
		document.frmadd.prodimg.focus();
		return false;
	}
	else 
	return true;
}

function checksubcat(frm)
{
	if(frm.category.value==0)
	{
		alert("Please Select Category");
		frm.category.focus();
		return false;
	}
	if(!CheckEmpty(frm.subcategory.value,"Sub Category"))
	{
		frm.subcategory.value='';
		frm.subcategory.focus();
		return false;
	}
	if(!CheckEmpty(frm.description.value,"Description"))
	{
		
		return false;
	}
	if(!Thumbnail12(frm.prodimg.value))
	{
		
		frm.prodimg.focus();
		return false;
	}
}

//Product Start
function CheckProductData(frm)
{
	if(frm.category.value==0)
	{
		alert("Please Select Category");
		frm.category.focus();
		return false;
	}
	if(!CheckEmpty(frm.productname.value,"Product Name"))
	{
		frm.productname.value='';
		frm.productname.focus();
		return false;
	}
	if(!CheckEmpty(frm.prodimg.value,"Thumbnail Image"))
	{
		frm.prodimg.focus();
		return false;
	}
	
}
function CheckProductDataEdit(frm)
{
	if(frm.category.value==0)
	{
		alert("Please Select Category");
		frm.category.focus();
		return false;
	}
	if(!CheckEmpty(frm.productname.value,"Product Name"))
	{
		frm.productname.value='';
		frm.productname.focus();
		return false;
	}
	//alert("coem");
	if(frm.prodimg.value!='')
	{
		
		var image11 = frm.prodimg.value;
		var imgtype11 = image11.indexOf('.',0);
			//	alert(imgtype11);
		
		var imgexten11=image11.substring(imgtype11+1,image11.length);
				//alert(imgexten11);
			if((imgexten11!='jpg') && (imgexten11!='JPG') && (imgexten11!='jpeg') && (imgexten11!='JPEG') && (imgexten11!='png') && (imgexten11!='PNG') )
			{
				alert("Please Select Valid JPG or JPEG or PNG Image File");
				frm.prodimg.focus();
				return false;
			}
	/*	
	 if(!Thumbnail(frm.prodimg.value))
	 {
		//alert("test");
		frm.prodimg.focus();
		return false;
	 }
	 */
	}
}

function Thumbnail(what){    
//Thumbnail Image Validation
		alert(what);

var image11 = frm.prodimg.value;
var imgtype11 = image11.indexOf('.',0);
		alert(imgtype11);

var imgexten11=image11.substring(imgtype11+1,image11.length);
		alert(imgexten11);
	if((imgexten11!='jpg') && (imgexten11!='JPG') && (imgexten11!='jpeg') && (imgexten11!='JPEG') && (imgexten11!='png') && (imgexten11!='PNG') )
	{
		alert("Please Select Valid JPG or JPEG or PNG Image File");
		frm.prodimg.focus();
		return false;
	}
}
function Enlarged(what){         // Enlarged Image Validation

var image11 = document.frmadd.enlargeimg.value;
var imgtype11 = image11.indexOf('.',0);
var imgexten11=image11.substring(imgtype11+1,image11.length);
	if((imgexten11!='jpg') && (imgexten11!='jpeg') && (imgexten11!='gif') && (imgexten11!='bmp') && (imgexten11!='png'))
	{
		alert("Please Select Valid JPG or JPEG or GIF or BMP or PNG Image File");
		document.frmadd.enlargeimg.focus();
		return false;
	}
}

//end of product function

// ----------------------------------Catalog Validation End Here  ------------------------------------------------//

//-----------------------------------Newsletter Validation Start Here -------------------------------------------//

function userlist(frm)                         // Admin add user
{
		if(frm.category.value==0)
		{	
			alert("Please Select Category");
			frm.category.focus();
			return false;
		}
		if(!CheckEmpty(frm.email.value,"Email Address"))
		{
			frm.email.focus();
			frm.email.value='';
			return false;
		}
		if(!CheckEmailAddr(frm.email.value,"Email"))
		{
			alert("Please Enter Valid Email Address");
			frm.email.focus();
			frm.email.value='';
			return false;
		}
		
		if(!CheckEmpty(frm.cemail.value,"Confirm Email Address"))
		{
			frm.cemail.focus();
			frm.cemail.value='';
			return false;
		}
		if(!CheckEmailAddr(frm.cemail.value,"Email"))
		{
			alert("Please Enter Valid Confirm Email Address");
			frm.cemail.focus();
			frm.cemail.value='';
			return false;
		}
		if(frm.email.value != frm.cemail.value)
		{
			alert("Email id And Confirm Email id Must be same");
			frm.cemail.focus();
			frm.cemail.value='';
			return false;
		}
		if(!CheckEmpty(frm.name.value,"Name"))
		{
			frm.name.value='';
			frm.name.focus();
			return false;
		}
		if(frm.country.value==0)
		{	
			alert("Please Select Country");
			frm.country.focus();
			return false;
		}
}   // end of the function 


function adduser(frm)           // user add validation
{
		if(!CheckEmpty(frm.email.value,"Email Address"))
		{
			frm.email.focus();
			frm.email.value='';
			return false;
		}
		if(!CheckEmailAddr(frm.email.value,"Email"))
		{
			alert("Please Enter Valid Email Address");
			frm.email.focus();
			frm.email.value='';
			return false;
		}
		
		if(!CheckEmpty(frm.cemail.value,"Confirm Email Address"))
		{
			frm.cemail.focus();
			frm.cemail.value='';
			return false;
		}
		if(!CheckEmailAddr(frm.cemail.value,"Email"))
		{
			alert("Please Enter Valid Confirm Email Address");
			frm.cemail.focus();
			frm.cemail.value='';
			return false;
		}
		if(frm.email.value != frm.cemail.value)
		{
			alert("Email id And Confirm Email id Must be same");
			frm.cemail.focus();
			frm.cemail.value='';
			return false;
		}
		
		
		if(!CheckEmpty(frm.name.value,"Name"))
		{
			frm.name.value='';
			frm.name.focus();
			return false;
		}
		if(frm.country.value==0)
		{	
			alert("Please Select Country");
			frm.country.focus();
			return false;
		}
}                         // end of the function

function SearchClicked()
{
	if(!CheckEmpty(document.frmSearch.txtSearch.value,"Search Text"))
	{
		document.frmSearch.txtSearch.focus();
		return ;
	}
	document.frmSearch.action="searchresults.php";	
	document.frmSearch.submit();
}//end of function


function Chgtxt(obj,pos)
{
	if(isNaN(obj.value))           //   Phone
	{
		alert("Enter the values [0-9]");
		obj.value='';
		document.frm.ph1.focus();
		return false;
	}
	if(obj.value.length ==3)
	{
		if(pos == 2)
		{
			document.frm.ph2.focus();
		}
		else if(pos == 3)
		{
			document.frm.ph3.focus();		
		}	
	}
	
}

function Chgtxt1(obj,pos)
{
	if(isNaN(obj.value))           //   Fax
	{
		alert("Enter the values [0-9]");
		obj.value='';
		document.frm.fa1.focus();
		return false;
	}
	if(obj.value.length ==3)
	{
		if(pos == 2)
		{
			document.frm.fa2.focus();
		}
		else if(pos == 3)
		{
			document.frm.fa3.focus();		
		}	
	}
}

function Chgtxt2(obj,pos)
{
	if(isNaN(obj.value))           //   Mobile
	{
		alert("Enter the values [0-9]");
		obj.value='';
		document.frm.ma1.focus();
		return false;
	}
	if(obj.value.length ==3)
	{
		if(pos == 2)
		{
			document.frm.ma2.focus();
		}
		else if(pos == 3)
		{
			document.frm.ma3.focus();		
		}	
	}
}

function sendmail()               // Sendmail_category.php
{
	if(document.frmmail.list.value == 0)
	{
		alert("Please Select Category List");
		document.frmmail.list.focus();
		return false;
	}
	if(document.frmmail.subject.value.split(" ").join("").length <='')
	{
		alert("Please Enter Subject");
		document.frmmail.subject.value='';
		document.frmmail.subject.focus();
		return false;
	}
}

function ValSearch()
{
	var frm = this.document.sublist;
	if(frm.selField.value == 0)
	{
		alert("Please Select First Filed");
		frm.selField.value='';
		frm.selField.focus();
		return false;
	}
	if(frm.selMatch.value == 0)
	{
		alert("Please Select Matching Field");
		frm.selMatch.value='';
		frm.selMatch.focus();
		return false;
	}
	if(frm.txtsearch.value.split(" ").join("").length <='')
	{
		alert("Please Enter Text Search Filed");
		frm.txtsearch.value='';
		frm.txtsearch.focus();
		return false;
	}
	
	frm.submit();
	return true;
}

//-----------------------------------Newsletter Validation End Here -------------------------------------------//

//----------------------------------Shipping Address Validation Start Here--------------------------//

function calship()
{
//window.document.forms.form1.shclik.value="1";

if(!CheckEmpty(document.frmShip.txtrzip.value,"Postal Code/Zip in Recipient Address"))
{
	document.frmShip.txtrzip.focus();
	return;
}

	if(document.frmShip.shmethod.selectedIndex > 0 &&  document.frmShip.txtrzip.value != "" )
	{
		
		dx = document.frmShip.shmethod.options[document.frmShip.shmethod.selectedIndex].value;
		
		
		dy = document.frmShip.txtrzip.value;
		
		
		
		//dz = document.frmShip.weight.value;
		dz = document.frmShip.hfTotWt.value;
		
		
		dctn = document.frmShip.hfTotAmt.value;


		var leftPos = 0;
		var topPos = 0;
		if (screen) 
		{
			leftPos = (screen.width / 2) - 100;
			topPos = (screen.height / 2) - 100;
		}		
		
		
		//openWind = window.open("https://colorprintingpros.com/calculateship.php?shmethod="+dx+"&szip="+dy+"&weight="+dz+"&carton="+dctn,"cals","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,screenY=1500,width=50,height=50");
		openWind = window.open("calship.php?shmethod="+dx+"&szip="+dy+"&weight="+dz+"&carton="+dctn,"cals","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=50,height=50,left=250,top=250");
	}	//end of if
}//end of function
function ValidateData(frm)
{	
   if(!CheckEmpty(frm.txtname.value,"Name in Billing Address"))
	{	
		frm.txtname.focus();
		return false;
	}
	if(!CheckEmpty(frm.txtaddr1.value,"Address Line1 in Billing Address"))
	{
		frm.txtaddr1.focus();
		return false;
	}
	
	if(!CheckEmpty(frm.txtcity.value,"City in Billing Address"))
	{
		frm.txtcity.focus();
		return false;
	}
	if(!CheckEmpty(frm.txtstate.value,"State in Billing Address"))
	{
		frm.txtstate.focus();
		return false;
	}
	if(!CheckEmpty(frm.txtzip.value,"Zipcode in Billing Address"))
	{
		frm.txtzip.focus();
		return false;
	}
	if(frm.txtcountry.selectedIndex == 0 )
	{
		alert("Please select a Country in Billing Address");
		frm.txtcountry.focus();
		return false;
	}
	if(frm.txtphone.value != "")
	{
		if(!IsFax(frm.txtphone.value,"Phone in Billing Address"))
		{
			frm.txtphone.focus();
			return false;
		}
	}
	if(!CheckEmailAddr(frm.txtemail.value,"Email in Billing Address"))
	{
		alert("Enter valid Email Address");
		frm.txtemail.focus();
		return false;
	}


	if(!CheckEmpty(frm.txtrname.value,"Name in Recipient Address"))
	{
		frm.txtrname.focus();
		return false;
	}
	if(!CheckEmpty(frm.txtraddr1.value,"Address Line1 in Recipient Address"))
	{
		frm.txtraddr1.focus();
		return false;
	}
	
	if(!CheckEmpty(frm.txtrcity.value,"City in Recipient Address"))
	{
		frm.txtrcity.focus();
		return false;
	}
	if(!CheckEmpty(frm.txtrstate.value,"State in Recipient Address"))
	{
		frm.txtrstate.focus();
		return false;
	}
	if(!CheckEmpty(frm.txtrzip.value,"Zipcode in Recipient Address"))
	{
		frm.txtrzip.focus();
		return false;
	}
	if(frm.txtrcountry.selectedIndex == 0 )
	{
		alert("Please select a Country in Recipient Address");
		frm.txtrcountry.focus();
		return false;
	}
	if(frm.txtrphone.value != "")
	{
		if(!IsFax(frm.txtrphone.value,"Phone in Recipient Address"))
		{
			frm.txtrphone.focus();
			return false;
		}
	}	

	if(frm.txtremail.value != "")
	{
		if(!CheckEmailAddr(frm.txtremail.value,"Email in Recipient Address"))
		{
			alert("Enter valid Email Address");
			frm.txtremail.focus();
			return false;
		}
	}	
}//end of function
function putAddress()
{
	document.frmShip.txtrname.value = document.frmShip.txtname.value;
	document.frmShip.txtraddr1.value = document.frmShip.txtaddr1.value;
	document.frmShip.txtraddr2.value = document.frmShip.txtaddr2.value;		
	document.frmShip.txtraddr3.value = document.frmShip.txtaddr3.value;
	document.frmShip.txtraddr4.value = document.frmShip.txtaddr4.value;		
	document.frmShip.txtrcity.value = document.frmShip.txtcity.value;		
	document.frmShip.txtrstate.value = document.frmShip.txtstate.value;
	document.frmShip.txtrzip.value = document.frmShip.txtzip.value;	
	document.frmShip.txtrcountry.value = document.frmShip.txtcountry.value;		
	document.frmShip.txtrphone.value = document.frmShip.txtphone.value;			
	document.frmShip.txtremail.value = document.frmShip.txtemail.value;				
	
}//end of function

//----------------------------------Shipping Address Validation End Here--------------------------//

//----------------------------------Admin Font Setting Start here ---------------------//
function CheckFonts(frm)
{

		if(!CheckEmpty(frm.afont_type.value,"Label Font type"))
		{
			frm.afont_type.focus();
			return false;
		}
		
		if(!CheckEmpty(frm.afont_size.value,"Label Font size"))
		{
			frm.afont_size.focus();
			return false;
		}
		if(!CheckEmpty(frm.astlye.value,"Label Font Stlye"))
		{
			frm.astlye.focus();
			return false;
		}

		if(!CheckEmpty(frm.alinkcolor.value,"Label Text color"))
		{
			frm.alinkcolor.focus();
			return false;
		}
		if(!CheckEmpty(frm.aalign.value,"Label Text Alignment"))
		{
			frm.aalign.focus();
			return false;
		}
		
		if(!CheckEmpty(frm.cfont_type.value,"Category Font type"))
		{
			frm.cfont_type.focus();
			return false;
		}
		
		if(!CheckEmpty(frm.cfont_size.value,"Category Font size"))
		{
			frm.cfont_size.focus();
			return false;
		}
		if(!CheckEmpty(frm.cstlye.value,"Category Font Stlye"))
		{
			frm.cstlye.focus();
			return false;
		}
		if(!CheckEmpty(frm.clinkcolor.value,"Category Text color"))
		{
			frm.clinkcolor.focus();
			return false;
		}
		if(!CheckEmpty(frm.calign.value,"Category Text Alignment"))
		{
			frm.calign.focus();
			return false;
		}
		
		if(!CheckEmpty(frm.ifont_type.value,"Item Font type"))
		{
			frm.ifont_type.focus();
			return false;
		}
		
		if(!CheckEmpty(frm.ifont_size.value,"Item Font size"))
		{
			frm.ifont_size.focus();
			return false;
		}
		if(!CheckEmpty(frm.istlye.value,"Item Font Stlye"))
		{
			frm.istlye.focus();
			return false;
		}
		
		if(!CheckEmpty(frm.ilinkcolor.value,"Item Text color"))
		{
			frm.ilinkcolor.focus();
			return false;
		}
		if(!CheckEmpty(frm.ialign.value,"Item Text Alignment"))
		{
			frm.ialign.focus();
			return false;
		}
		
		if(!CheckEmpty(frm.ffont_type.value,"Article Font type"))
		{
			frm.ffont_type.focus();
			return false;
		}
		
		if(!CheckEmpty(frm.ffont_size.value,"Article Font size"))
		{
			frm.ffont_size.focus();
			return false;
		}
		if(!CheckEmpty(frm.fstlye.value,"Article Font Stlye"))
		{
			frm.fstlye.focus();
			return false;
		}
		
		if(!CheckEmpty(frm.flinkcolor.value,"Article Text color"))
		{
			frm.flinkcolor.focus();
			return false;
		}
		if(!CheckEmpty(frm.falign.value,"Article Text Alignment"))
		{
			frm.falign.focus();
			return false;
		}

		
}

//--------------------------Admin Font Setting End Here -----------------------//
//--------------------------Admin Submit Support Request Start Here -----------------------//

function CheckSupport(frm)
{

		if(!CheckEmpty(frm.adminname.value,"Name"))
		{
			frm.adminname.focus();
			return false;
		}
		if(!CheckEmpty(frm.email.value,"Email"))
		{
			frm.email.focus();
			return false;
		}
		if(!CheckEmailAddr(frm.email.value,"Email"))
		{
			alert("Please Enter Valid Email Address");
			frm.email.focus();
			frm.email.value='';
			return false;
		}
		if(frm.request.value==0)
		{
			alert("Please Select Nature of request");
			frm.request.focus();
			return false;
		}
		if(!CheckEmpty(frm.subject.value,"Subject"))
		{
			frm.subject.focus();
			return false;
		}
}
//--------------------------Admin Submit Support Request End Here -----------------------//

//-------------------------- Email Subsciber validation Start Here-------------------//
function EmailSubscriber(frm)
{
		if(!CheckEmpty(frm.email.value,"Email"))
		{
			frm.email.focus();
			return false;
		}
		if(!CheckEmailAddr(frm.email.value,"Email"))
		{
			alert("Please Enter Valid Email Address");
			frm.email.focus();
			frm.email.value='';
			return false;
		}
}
//-------------------------- Email Subsciber validation End Here-------------------//

//-------------------------- Site Search validation Start Here-------------------//
function SiteSearch(frm)
{
		if(!CheckEmpty(frm.Search.value,"Site Search"))
		{
			frm.Search.focus();
			return false;
		}
}
//-------------------------- Site Search validation End Here-------------------//

function SendMail()
{
	if(document.frmmail.list.value == 0)
	{
		alert("Please Select Search List");
		document.frmmail.list.focus();
		return false;
	}
	if(document.frmmail.fromemail.value.split(" ").join("").length <='')
	{
		alert("Please Enter From Email");
		document.frmmail.fromemail.value='';
		document.frmmail.fromemail.focus();
		return false;
	}
	if(document.frmmail.fromname.value.split(" ").join("").length <='')
	{
		alert("Please Enter From Name");
		document.frmmail.fromname.value='';
		document.frmmail.fromname.focus();
		return false;
	}
	if(document.frmmail.subject.value.split(" ").join("").length <='')
	{
		alert("Please Enter Subject");
		document.frmmail.subject.value='';
		document.frmmail.subject.focus();
		return false;
	}
}

