function validateaffiliatelogin()
{
	var frm = document.frmlogin;
	if(!isValidEntry(frm.username, "User Name"))
	return false;
	if( GenValidation(frm.pwd, 'Password', 'Password', '') == 0 )
	 return false ;
}

function validatelogin()
{
	var frm = document.frmlogin;
	if(!isValidEntry(frm.username, "User Name"))
	return ;
	if( GenValidation(frm.pwd, 'Password', 'Password', '') == 0 )
	 return ;
	frm.action="loginquery.php";
	frm.submit();
}


//refinebasket

function funaddcolorsses()
{
	var frm = document.frmcolors;
	var c=0;
			for(i=0;i<frm.elements.length;i++) 
			{
				if((frm.elements[i].type == "checkbox") && (frm.elements[i].checked == true)) 
				{
					c++;
				} // if statement
			} // for 
			if(c == 0)
			{
				alert("Please select any one color.");
				return false;
			}
			frm.kw.value="ADDCOLORS";
}

function validateaffilate()
{
	var frm = document.frmsiteaffiliate;
	frm.kw.value="Addaffilate";
	if(!isValidEntry(frm.firstname, "First Name"))
	return false;
	if(!isValidEntry(frm.lastname, "Last Name"))
	return false;
	if(!isValidEntry(frm.address, "Address"))
	return false;
	if(!isValidEntry(frm.compname, "Company Name"))
	return false;
	if(!isValidSelect(frm.country, "Country"))
	return false;
	if(!isValidSelect(frm.state, "State"))
	return false;
	if(!isValidEntry(frm.city, "City"))
	return false;
	if(!isValidZipcode(frm.zip,'yes'))
	return false;
	if(!isValidPhone(frm.phone,'Phone Number','yes'))
	 return false;
	if(!isValidEmail(frm.emailaddress,'yes'))
	 return false;
	 if(!isPaypalid(frm.paypalid,'yes'))
	 return false;
	 if(!isValidEntry(frm.username, "User Name"))
	return false;
	if( GenValidation(frm.pwd, 'New Password', 'Password', '') == 0 )
	return false;
	if( GenValidation(frm.confirmpwd, 'Confirm Password', '', '') == 0 )
	return false;
	if(!isValidConfirmPassword(frm.pwd, frm.confirmpwd))
	return false;
	if(frm.terms.checked==false)
		{
			alert("Please accept Terms and Conditions");
			return false;
		}
}

function validateitemchanges(modelid)
{
	var frm = document.frmviewitems;
	frm.model.value=modelid;
	frm.action="aff_applyitemchanges.php";
	frm.submit();
}

function validateitemchanges1(modelid)
{
	var frm = document.frmviewitems;
	
	frm.model.value=modelid;
	frm.action="applyitemchanges.php";
	frm.submit();
}
function validatejewelleryitemchanges1(modelid)
{
	var frm = document.frmviewitems;
	frm.model.value=modelid;
	frm.action="jewelleryapplyitemchanges.php";
	frm.submit();
}
function validateitemchanges1(modelid)
{
	var frm = document.frmviewitems;
	frm.model.value=modelid;
	frm.action="applyitemchanges.php";
	frm.submit();
}
function validateitem()
{
	var frm=document.frmadditem;
	frm.kw.value="additem";
	if(!isValidEntry(frm.itemcode, "Item Code"))
	return false;
	if(!isValidEntry(frm.desc, "Description"))
	return false;
	if(!isValidNumber(frm.morder,'Minimum Order','yes'))
 	return false;
	if(!isValidAmount(frm.acost,'Actual Cost','yes'))
 	return false;
	if(!isValidNumber(frm.qoh,'Quantity on Hand','yes'))
 	return false;
	if(!isValidNumber(frm.rel,'Reorder Level','yes'))
 	return false;
	if(!isValidNumber(frm.sstock,'Safety Stock','yes'))
 	return false;
	if(frm.sizecatname.value=="T-Shirt")
		{
			var c=0;
			for(i=0;i<frm.elements.length;i++) 
			{
				if((frm.elements[i].type == "checkbox") && (frm.elements[i].checked == true)) 
				{
					c++;
				} // if statement
			} // for 
			if(c == 0)
			{
				alert("Please select any one Size.");
				return false;
			}
			
}

}

function vaidateitemroductdetails()
{
	var frm=document.frmadditem;
	frm.kw.value="additemproduct";
	if(!isValidEntry(frm.itemcode, "Item Code"))
	return false;
	if(!isValidEntry(frm.desc, "Description"))
	return false;
	if(!isValidNumber(frm.morder,'Minimum Order','yes'))
 	return false;
	if(!isValidAmount(frm.acost,'Actual Cost','yes'))
 	return false;
	if(!isValidNumber(frm.qoh,'Quantity on Hand','yes'))
 	return false;
	if(!isValidNumber(frm.rel,'Reorder Level','yes'))
 	return false;
	if(!isValidNumber(frm.sstock,'Safety Stock','yes'))
 	return false;
if(frm.maincatname.value=="T-Shirt")
{
			var c=0;
			for(i=0;i<frm.elements.length;i++) 
			{
				if((frm.elements[i].type == "checkbox") && (frm.elements[i].checked == true)) 
				{
					c++;
				} // if statement
			} // for 
			if(c == 0)
			{
				alert("Please select any one Size.");
				return false;
			}
			
}

	
}


function funeditProfile()
{
	var frm = document.frmeditaffiliate;
	frm.kw.value="Editaffilate";
	if(!isValidEntry(frm.firstname, "First Name"))
	return false;
	if(!isValidEntry(frm.lastname, "Last Name"))
	return false;
	if(!isValidEntry(frm.address, "Address"))
	return false;
	if(!isValidEntry(frm.compname, "Company Name"))
	return false;
	if(!isPaypalid(frm.paypalid,'yes'))
	 return false;
	if(!isValidSelect(frm.country, "Country"))
	return false;
	if(!isValidSelect(frm.state, "State"))
	return false;
	if(!isValidEntry(frm.city, "City"))
	return false;
	if(!isValidZipcode(frm.zip,'yes'))
	return false;
	if(!isValidPhone(frm.phone,'Phone Number','yes'))
	 return false;
}

function funchangepwd(sp)
{
 var frm = document.frmchangepwd;
   var oldpwd=frm.oldpwd.value;
  	if(!isValidEntry(frm.oldpwd,'Old Password'))
	 return false;
    if(!isValidEntry(frm.newpwd,'New Password'))
	 return false;
	  if(!isValidEntry(frm.repwd,'Confirm Password'))
	 return false;
	 if(!isValidConfirmPassword(frm.newpwd,frm.repwd))
	 return false;
	 
    if(sp!=oldpwd)
	 {
	 alert("Old Password is wrong");
	  frm.oldpwd.value="";	  
	  frm.oldpwd.focus();
	  return false;
	  }
	frm.kw.value="CHANGEPWD";
	
}

function viewdetails(id)
{
		var URL="aff_viewitemdetails.php?model="+id;
        var newWin = window.open(URL,'myChild',"height=500,width=600,menubar=no,resizable=yes")
        newWin.focus()
}

function viewnewsdetails(id)
{
		var URL="aff_viewnewsdetails.php?newsid="+id;
        var newWin = window.open(URL,'myChild',"height=500,width=600,menubar=no,resizable=yes")
        newWin.focus()
}
function viewdetails1(id)
{
		var URL="aff_viewapproveditemdetails.php?model="+id;
        var newWin = window.open(URL,'myChild',"height=500,width=600,menubar=no,resizable=yes")
        newWin.focus()
}

function popups(id)
{
		//alert(id);
		var URL=id;
        var newWin = window.open(URL,'myChild',"height=200,width=600,menubar=no,resizable=yes")
        newWin.focus()
}
function  productlink(val,url)
{
	var frm=document.frmproduct;
	frm.maincatname.value=val;
	frm.action=url;
	frm.submit();
	
}
function designerproductlink(id,url)
{
	var frm=document.frmproduct;
	frm.affid.value=id;
	frm.action=url;
	frm.submit();
	
}

function validatecontinue(frm,url)
{
	frm.action=url;
	frm.submit();
}

function validproductimage(val)
{
	
	var cell=document.getElementById("hidamt");
	cell.innerHTML=val;
}
function validaterefinementproduct()
{
	var frm=document.frmproducttwo;
	frm.kw.value="Refinementproduct";
	if(!isValidEntry(frm.productimage, "Product Image"))
	return false;
	if(!isValidEntry(frm.refinename, "Name"))
	return false;
	if(!isValidEntry(frm.refineimage, "Image"))
	return false;
}
function validatepagecontinue()
{
	var frm=document.frmproductfour;
	frm.action="aff_selectedrefinement.php";
	frm.submit();
}
function validatepagecontinue1()
{
	var frm=document.frmproductfour;
	frm.action="selectedrefinement.php";
	frm.submit();
}
function viewownrefinepage()
{
	var frm=document.frmproductfour;
	frm.action="aff_viewownrefinements.php";
	frm.submit();
}
function viewownrefinepage1()
{
	var frm=document.frmproductfour;
	frm.action="viewownrefinements.php";
	frm.submit();
}
function validatecompose()
{
	var frm=document.frmcompose;
	frm.kw.value="composemessage";
	if(!isValidEntry(frm.subject, "Subject"))
	return false;
}

function validatenewstonewsletter()
{
	var frm=document.frmcompose;
	frm.kw.value="addnews";
	if(!isValidEntry(frm.subject, "Subject"))
	return false;
}
function validateeditnewsletter()
{
	var frm=document.frmcompose;
	frm.kw.value="Editnews";
	if(!isValidEntry(frm.subject, "Subject"))
	return false;
}
function validatecompose1()
{
	var frm=document.frmcompose;
	frm.kw.value="composemessage";
	if(!isValidSelect(frm.username,'User Name'))
	return false;
	if(!isValidEntry(frm.subject, "Subject"))
	return false;
	
}

function change()
{
  //alert(document.frminbox.moveto.value);
  check="";
	 var k=document.frminbox.elements.length;
	 for(i=0;i<k;i++)
	 {
		  if(document.frminbox.elements[i].name=='checkToDelete' && document.frminbox.elements[i].checked)
		  {
		   check+=document.frminbox.elements[i].value+",";
		  }
	 }
	 if(check=="")
	 {
		  alert("Select any folder to move.");
		  return false;
	 }
	 else
	 {
		  document.frminbox.msgdelete.value=check;
		 //alert(document.frminbox.msgdelete.value);
		 //return false;
	 }
	document.frminbox.kw.value="changefolder";
 	document.frminbox.action="composequery.php";
	document.frminbox.submit();
 //location.href="composequery.php?msgid="+document.frminbox.msgdelete.value+"&folder_id="+document.frminbox.moveto.value;
  //alert("change_msg.php?msgid="+document.frminbox.msgdelete.value+"&folder_id="+document.frminbox.moveto.value);
  //return false;
}

function create_folder()
{
 document.frmcreate.folder.style.visibility="visible";
 document.frmcreate.create.style.visibility="visible";
}
function createfolder()
{

if(document.frmcreate.folder.value=="")
 {
  alert("You must enter a name to create a folder.");
  document.frmcreate.folder.focus();
  return false;
 }
  document.frmcreate.hid.value="createfolder";
 return true;
}

function viewmessage(frm,id,url,val)
{
	
	frm.messageid.value=id;
	frm.kw.value=val;
	frm.action=url;
	frm.submit();
}

function deleting(frm)
{
	 check="";
	 var k=frm.elements.length;
	
	 for(i=0;i<k;i++)
	 {
		  if(frm.elements[i].name=='checkToDelete' && frm.elements[i].checked)
		  {
		   check+=frm.elements[i].value+",";
		  }
	 }
	 if(check=="")
	 {
		  alert("Select any one to delete.");
	 }
	 else
	 {
		  frm.msgdelete.value=check;
		  frm.kw.value="deletemsg";
		 // alert(document.frminbox.msgdelete.value);
		  frm.action="composequery.php";
		  frm.submit();

	 }
}
function deleteoutboxmsg(frm)
{
	 check="";
	 var k=frm.elements.length;
	
	 for(i=0;i<k;i++)
	 {
		  if(frm.elements[i].name=='checkToDelete' && frm.elements[i].checked)
		  {
		   check+=frm.elements[i].value+",";
		  }
	 }
	 if(check=="")
	 {
		  alert("Select any one to delete.");
	 }
	 else
	 {
		  frm.msgdelete.value=check;
		  frm.kw.value="deleteoutboxmsg";
		 // alert(frm.kw.value);
		 //alert(frm.msgdelete.value);
		  frm.action="composequery.php";
		  frm.submit();

	 }
}

function validatefolder()
{
	var frm=document.frmfolder;
	frm.action="aff_myfolders.php";
	frm.submit();
}

function validatemsgfolder(id)
{
	var frm=document.frmfolder;
	frm.folderid.value=id;
	frm.action="viewfoldermsgs.php";
	frm.submit();
}
function deletingfoldermessage(frm)
{
	 check="";
	 var k=frm.elements.length;
	
	 for(i=0;i<k;i++)
	 {
		  if(frm.elements[i].name=='checkToDelete' && frm.elements[i].checked)
		  {
		   check+=frm.elements[i].value+",";
		  }
	 }
	 if(check=="")
	 {
		  alert("Select any one to delete.");
	 }
	 else
	 {
		  frm.msgdelete.value=check;
		  frm.kw.value="deletefoldermsg";
		 // alert(document.frminbox.msgdelete.value);
		  frm.action="composequery.php";
		  frm.submit();

	 }
}
function  viewaffiliateproducts(frm,val,url)
{
	frm.affid.value=val;
	frm.action=url;
	frm.submit();
}

function  viewdesignerrefinementapprove(frm,val,url,resval)
{
	frm.extrinmodelid.value=val;
	frm.kw1.value=resval;
	frm.action=url;
	frm.submit();
}

function viewaffproductdetails(id,val)
{
	var frm=document.frmviewitems;
	frm.model.value=id;
	frm.kw1.value=val;
	frm.action="viewaffproductdetails.php";
	frm.submit();
}
function viewajewelleryffproductdetails(id,val)
{
	var frm=document.frmviewitems;
	frm.model.value=id;
	frm.kw1.value=val;
	frm.action="viewjewelleryaffproductdetails.php";
	frm.submit();
}

function viewaffiliaterefinements(id,val)
{
	var frm=document.frmviewitems;
	frm.model.value=id;
	frm.kw1.value=val;
	frm.action="viewaffiliatecomprefinements.php";
	frm.submit();
}

function viewadminrefinements(id,val)
{
	var frm=document.frmviewitems;
	frm.model.value=id;
	frm.kw1.value=val;
	frm.action="viewadminrefinements.php";
	frm.submit();
}
function viewadminjewelleryrefinements(id,val)
{
	var frm=document.frmviewitems;
	frm.model.value=id;
	frm.kw1.value=val;
	frm.action="viewadminjewelleryrefinements.php";
	frm.submit();
}

function viewinventoryadminjewelleryrefinements(id,val)
{
	var frm=document.frmviewitems;
	frm.model.value=id;
	frm.kw1.value=val;
	frm.action="viewinventoryadminjewelleryrefinements.php";
	frm.submit();
}

function viewapproveaffproducts(id,val)
{
	var frm=document.frmviewitems;
	frm.model.value=id;
	frm.kw1.value=val;
	frm.action="viewaffapproveproducts.php";
	frm.submit();
}

function viewinventoryapproveaffproducts(id,val)
{
	var frm=document.frmviewitems;
	frm.model.value=id;
	frm.kw1.value=val;
	frm.action="viewinventoryaffapproveproducts.php";
	frm.submit();
}

function viewapprovejewelleryaffproducts(id,val)
{
	var frm=document.frmviewitems;
	frm.model.value=id;
	frm.kw1.value=val;
	frm.action="viewjewelleryaffapproveproducts.php";
	frm.submit();
}
function viewinventoryapprovejewelleryaffproducts(id,val)
{
	var frm=document.frmviewitems;
	frm.model.value=id;
	frm.kw1.value=val;
	frm.action="viewinventoryjewelleryaffapproveproducts.php";
	frm.submit();
}
function viewapproveadminproducts(id,val)
{
	var frm=document.frmviewitems;
	frm.model.value=id;
	frm.kw1.value=val;
	frm.action="viewadminapproveproducts.php";
	frm.submit();
}
function viewapprovejewelleryadminproducts(id,val)
{
	var frm=document.frmviewitems;
	frm.model.value=id;
	frm.kw1.value=val;
	frm.action="viewadminapprovejewelleryproducts.php";
	frm.submit();
}
function  Activebulkcreation(frm,val,url)
{
	frm.kw.value="Activebulkcreation";
	frm.bulkid.value=val;
	frm.action=url;
	frm.submit();
}
function  viewdesigntoolcolorproducts(frm,val,url)
{
	frm.refcatid.value=val;
	frm.action=url;
	frm.submit();
}
function  validatedeclinedproduct(frm,id,val,url)
{
	if(confirm("Do you want to Decline this Product?"))
	{
	frm.productid.value=id;
	frm.kw.value=val;
	frm.action=url;
	frm.submit();
	}
}


function  validatemarketapproveproduct(frm,id,val,url)
{
	if(confirm("Do you want to Approve this Product?"))
	{
	frm.productid.value=id;
	frm.kw.value=val;
	frm.action=url;
	frm.submit();
	}
}
function  validatedeclinerefinement(frm,val,url)
{
	if(confirm("Do you want to Decline this Refinement?"))
	{
	frm.kw.value=val;
	frm.action=url;
	frm.submit();
	}
}


function validateitemproductdelete(frm,val,url,kwval)
{
	if(confirm("Do you want to Delete this Product?"))
	{
	frm.kw.value=kwval;
	frm.modelid.value=val;
	frm.action=url;
	frm.submit();
	}
}

function validategalleryproductdetails()
{
	var frm=document.frmadditem;
	frm.kw.value="addgalleryproductdetails";
	if(!isValidEntry(frm.itemcode, "Item Code"))
	return false;
	if(!isValidEntry(frm.desc, "Description"))
	return false;
	if(!isValidNumber(frm.morder,'Minimum Order','yes'))
 	return false;
	if(!isValidAmount(frm.acost,'Actual Cost','yes'))
 	return false;
	if(!isValidNumber(frm.qoh,'Quantity on Hand','yes'))
 	return false;
	if(!isValidNumber(frm.rel,'Reorder Level','yes'))
 	return false;
	if(!isValidNumber(frm.sstock,'Safety Stock','yes'))
 	return false;
	
}
function viewrefinementdetails(id)
{
		var URL="aff_viewrefinementdetails.php?model="+id;
        var newWin = window.open(URL,'myChild',"height=500,width=600,menubar=no,resizable=yes")
        newWin.focus()
}


function viewjewelleryrefinementdetails(id)
{
		var URL="aff_viewjewelleryrefinementdetails.php?model="+id;
        var newWin = window.open(URL,'myChild',"height=500,width=600,menubar=no,resizable=yes")
        newWin.focus()
}
function viewrefinementitemdetails(id,val)
{
		var URL="aff_viewrefinementitemdetails.php?model="+id+"&value="+val;
        var newWin = window.open(URL,'myChild',"height=500,width=600,menubar=no,resizable=yes,scrollbars=1")
        newWin.focus()
}


function viewdesignerrefinementitemdetails(id,val)
{
		var URL="des_viewrefinementsdetails.php?model="+id+"&value="+val;
        var newWin = window.open(URL,'myChild',"height=320,width=600,menubar=no,resizable=yes,scrollbars=yes")
        newWin.focus()
}



function  viewrefinementsitemdetails(frm,val,url)
{
	frm.modelid.value=val;
	frm.action=url;
	frm.submit();
}

function viewcategorywiserefinements(id)
{
var frm = document.frmrefinementcategory;
frm.refinecategory.value=id;
frm.action="aff_designerrefinements.php";
frm.submit();
}

function validaterequestrefinement(id,extrinid)
{
	var frm = document.frmdesignerrefinements;
	frm.designerusername.value=id;
	frm.refinementid.value=extrinid;
	frm.action="aff_refinementrequest.php";
	frm.submit();
}

function  editproductitemdetails(frm,val,url,pgid)
{
	frm.model.value=val;
	frm.pageid.value=pgid;
	frm.action=url;
	frm.submit();
}

function validateedititem()
{
	var frm=document.frmedititem;
	frm.kw.value="Edititemdetails";
	if(!isValidEntry(frm.itemcode, "Item Code"))
	return false;
	if(!isValidEntry(frm.desc, "Description"))
	return false;
	if(!isValidNumber(frm.morder,'Minimum Order','yes'))
 	return false;
	if(!isValidAmount(frm.acost,'Actual Cost','yes'))
 	return false;
	if(!isValidNumber(frm.qoh,'Quantity on Hand','yes'))
 	return false;
	if(!isValidNumber(frm.rel,'Reorder Level','yes'))
 	return false;
	if(!isValidNumber(frm.sstock,'Safety Stock','yes'))
 	return false;
	if(frm.maincatname.value=="T-Shirt")
{
			var c=0;
			for(i=0;i<frm.elements.length;i++) 
			{
				if((frm.elements[i].type == "checkbox") && (frm.elements[i].checked == true)) 
				{
					c++;
				} // if statement
			} // for 
			if(c == 0)
			{
				alert("Please select any one Size.");
				return false;
			}
			
}


}


function validateeditjewelleryitem()
{
	var frm=document.frmedititem;
	frm.kw.value="jewelleryEdititemdetails";
	if(!isValidEntry(frm.itemcode, "Item Code"))
	return false;
	if(!isValidEntry(frm.desc, "Description"))
	return false;
	if(!isValidNumber(frm.morder,'Minimum Order','yes'))
 	return false;
	if(!isValidAmount(frm.acost,'Actual Cost','yes'))
 	return false;
	if(!isValidNumber(frm.qoh,'Quantity on Hand','yes'))
 	return false;
	if(!isValidNumber(frm.rel,'Reorder Level','yes'))
 	return false;
	if(!isValidNumber(frm.sstock,'Safety Stock','yes'))
 	return false;
}

function validateeditrefinementjewelleryitemdetails()
{
	var frm=document.frmedititem;
	frm.kw.value="jewelleryeditrefinementitemdetails";
	if(!isValidEntry(frm.itemcode, "Item Code"))
	return false;
	if(!isValidEntry(frm.desc, "Description"))
	return false;
	if(!isValidNumber(frm.morder,'Minimum Order','yes'))
 	return false;
	if(!isValidAmount(frm.acost,'Actual Cost','yes'))
 	return false;
	if(!isValidNumber(frm.qoh,'Quantity on Hand','yes'))
 	return false;
	if(!isValidNumber(frm.rel,'Reorder Level','yes'))
 	return false;
	if(!isValidNumber(frm.sstock,'Safety Stock','yes'))
 	return false;
	
}

function validateeditrefinementitemdetails()
{
	var frm=document.frmedititem;
	frm.kw.value="editrefinementitemdetails";
	if(!isValidEntry(frm.itemcode, "Item Code"))
	return false;
	if(!isValidEntry(frm.desc, "Description"))
	return false;
	if(!isValidNumber(frm.morder,'Minimum Order','yes'))
 	return false;
	if(!isValidAmount(frm.acost,'Actual Cost','yes'))
 	return false;
	if(!isValidNumber(frm.qoh,'Quantity on Hand','yes'))
 	return false;
	if(!isValidNumber(frm.rel,'Reorder Level','yes'))
 	return false;
	if(!isValidNumber(frm.sstock,'Safety Stock','yes'))
 	return false;
	
}


function  validaterefinementstatus(frm,val,url,pgid,val1)
{
	if(confirm("Do you want to Inactive this Refinement?"))
	{
		frm.model.value=val;
		frm.kw1.value=val1;
		frm.pageid.value=pgid;
		frm.action=url;
		frm.submit();
	}
}

function validatestatusrefinement()
{
var frm=document.frmstatusrefinement;
frm.kw.value="refinementstatus";
if(!isValidEntry(frm.comments, "Reason for Inactive"))
	return false;
}


function  validatedeleterefinement(frm,val,url,pgid,val1)
{
	if(confirm("Do you want to Delete this Refinement?"))
	{
		frm.model.value=val;
		frm.kw1.value=val1;
		frm.pageid.value=pgid;
		frm.action=url;
		frm.submit();
	}
}

function  validateproductstatus(frm,val,url,pgid,val1)
{
	if(confirm("Do you want to Inactive this Product?"))
	{
		frm.model.value=val;
		frm.kw1.value=val1;
		frm.pageid.value=pgid;
		frm.action=url;
		frm.submit();
	}
}
function validatestatusproduct(val)
{
var frm=document.frmstatusproduct;
frm.kw.value="productstatus";
if(val=="Inactive")
{
if(!isValidEntry(frm.comments, "Reason for Inactive"))
	return false;
}
else if(val=="Delete")
{
if(!isValidEntry(frm.comments, "Reason for Delete"))
	return false;
}
}


function  validateproductdelete(frm,val,url,pgid,val1)
{
	if(confirm("Do you want to Delete this Product?"))
	{
		frm.model.value=val;
		frm.kw1.value=val1;
		frm.pageid.value=pgid;
		frm.action=url;
		frm.submit();
	}
}

function validatecoupon()
{
	var frm=document.frmaddcoupon;
	frm.kw.value="addcoupon";
	if(!isValidEntry(frm.coupcode, "Coupon Code"))
	return false;
	if(!isValidNumber(frm.coupname,'Dscount','yes'))
 	return false;
	if(!isValidEntry(frm.startdate, "Start Date"))
	return false;
	if(!isValidEntry(frm.enddate, "End Date"))
	return false;
if((isValidEntry(frm.startdate, "Banner Start Date"))&&(isValidEntry(frm.enddate, "Banner End Date")))
		{
			year1=frm.startdate.value.substr(0,4);
			month1=frm.startdate.value.substr(5,2);
			date1=frm.startdate.value.substr(8,2);
			year=frm.enddate.value.substr(0,4);
			month=frm.enddate.value.substr(5,2);
			date=frm.enddate.value.substr(8,2);
			if((year) < (year1))
			
			{
				alert("start date must be less than end date");
				return false;
			}
			if((year == year1)&&(month < month1))
			{ 
				alert("start date must be less than end date");
				return false;
			}
			if((year == year1)&&(month == month1))
			{
				if(date<date1)
				{
				alert("start date must be less than end date");
				return false;
				}
			
			}		
		}
	
}

function  validatecouponnews(frm,val,pgid,url)
{
	frm.couponcode.value=val;
	frm.pageid.value=pgid;
	frm.action=url;
	frm.submit();
}

function validatemarketproduct()
{
var frm=document.frmaddproduct;
frm.kw.value="addtempproduct";
if(!isValidEntry(frm.productname,'Product Name'))
	return false;
if(!isValidEntry(frm.productdesc,'Product Description'))
	return false;
if(!isValidEntry(frm.productimage, "Product  Image"))
	return false;

var productimage=frm.productimage.value;
		if(productimage != "")
			{
				if (!((productimage.substring(productimage.lastIndexOf(".")+1)=="jpeg") || (productimage.substring(productimage.lastIndexOf(".")+1)=="jpeg") || (productimage.substring(productimage.lastIndexOf(".")+1)=="jpg") ||(productimage.substring(productimage.lastIndexOf(".")+1)=="jpg") ))
				{
					alert("               Invalid File Format. \n Accepts only  jpeg or jpg files with right dimensions only!");
					frm.productimage.focus();
					return false; 
				  }
		   }

if(!isValidEntry(frm.refname,'Refinement Name'))
	return false;
if(!isValidEntry(frm.refimage, "Refinement  Image"))
	return false;

var refimage=frm.refimage.value;
		if(refimage != "")
			{
				if (!((refimage.substring(refimage.lastIndexOf(".")+1)=="jpeg") || (refimage.substring(refimage.lastIndexOf(".")+1)=="gif") || (refimage.substring(refimage.lastIndexOf(".")+1)=="jpg") ||(refimage.substring(refimage.lastIndexOf(".")+1)=="png") ))
				{
					alert("               Invalid File Format. \n Accepts only  jpeg or jpg files with right dimensions only!");
					frm.refimage.focus();
					return false; 
				  }
		   }


}

function validatemarketproducttwo()
	{
		var frm = document.frmmproducttwo;
		frm.kw.value="addproduct";
		var c=0;
		for(i=0;i<frm.elements.length;i++) 
		{
			if((frm.elements[i].type == "checkbox") && (frm.elements[i].checked == true)) 
			{
				c++;
			} // if statement
		} // for 
		if(c == 0)
		{
			alert("Please select Category/SubCategory");
			return false;
		}
 }

function validateproductitem(id)
{
var frm =document.frmitemproduct;

	frm.kw.value="additem";
	frm.productid.value=id;
	if(!isValidEntry(frm.itemcode, "Item Code"))
	return false;
	if(!isValidEntry(frm.itemdesc, "Item Description"))
	return false;
	if(!isValidNumber(frm.morder,'Minimum Order','yes'))
 	return false;
	if(!isValidAmount(frm.acost,'Actual Cost','yes'))
 	return false;
	if(!isValidNumber(frm.qoh,'Quantity on Hand','yes'))
 	return false;
	if(!isValidNumber(frm.rel,'Reorder Level','yes'))
 	return false;
	if(!isValidNumber(frm.sstock,'Safety Stock','yes'))
 	return false;
	
if(frm.maincatname.value=="T-Shirt")
		{
			var c=0;
			for(i=0;i<frm.elements.length;i++) 
			{
				if((frm.elements[i].type == "checkbox") && (frm.elements[i].checked == true)) 
				{
					c++;
				} // if statement
			} // for 
			if(c == 0)
			{
				alert("Please select any one Size.");
				return false;
			}
			
}

}

function validatemarketproductdelete(frm,id,pgid,url)
{
if(confirm("Are you sure you want to Delete?"))
	{
	
	frm.productid.value=id;
	frm.pageid.value=pgid;
	frm.kw.value="Delete";
	frm.action=url;
	frm.submit();
	}
}

function viewmarketproductdetails(frm,id,pgid,val,url)
{
frm.productid.value=id;
frm.kw.value=val;
frm.pageid.value=pgid;
frm.action=url;
frm.submit();
}

function validatecontinuerefinement(frm,url,id,pageid)
{
	frm.productid.value=id;
	frm.pgid.value=pageid;
	frm.action=url;
	frm.submit();
}

function validateitemdetails(frm,url,id,pgid)
{
	frm.productid.value=id;
	frm.pageid.value=pgid;
	frm.action=url;
	frm.submit();
}


function validateeditmarketitemproductdetails()
{
var frm =document.frmitemproduct;
	frm.kw.value="Edititemdetails";
	if(!isValidEntry(frm.itemcode, "Item Code"))
	return false;
	if(!isValidEntry(frm.itemdesc, "Item Description"))
	return false;
	if(!isValidNumber(frm.morder,'Minimum Order','yes'))
 	return false;
	if(!isValidAmount(frm.acost,'Actual Cost','yes'))
 	return false;
	if(!isValidNumber(frm.qoh,'Quantity on Hand','yes'))
 	return false;
	if(!isValidNumber(frm.rel,'Reorder Level','yes'))
 	return false;
	if(!isValidNumber(frm.sstock,'Safety Stock','yes'))
 	return false;
	
}

function validteinventoryproductinactive(frm,id,pgid,val,url)
{
if(confirm("Are you sure you want to Inactive?"))
{
frm.productid.value=id;
frm.kw.value=val;
frm.pageid.value=pgid;
frm.action=url;
frm.submit();
}
}

function  validateorder(frm,val,url)
{
	frm.order_id.value=val;
	frm.action=url;
	frm.submit();
}

function validateaffiliateorders(frm,id,url,val)
{
	frm.user_id.value=id;
	frm.order_type.value=val
	frm.action=url;
	frm.submit();
}
function  validateaffiliateorderdetails(frm,id,val,url)
{
	frm.order_userid.value=id;
	frm.order_id.value=val;
	frm.action=url;
	frm.submit();
}
function validatecontinueshoporders(frm,url,val)
{
	frm.order_type.value=val;
	frm.action=url;
	frm.submit();
}
function validatem_addtocart(id)
{
var frm=document.frmdesignerrefinements;
frm.refinementid.value=id;
frm.action="d_addtocart.php";
frm.submit();
}

function validate_designeraddtocart(id,val)
{
var frm=document.frmdesignerrefinements;
frm.refinementid.value=id;
frm.exclusivetype.value=val;
frm.action="d_addtocart.php";
frm.submit();
}
function validate_exclusiverefinement(id)
{
var frm=document.frmdesignerrefinements;
frm.refinementid.value=id;
frm.action="aff_designerexclusiverefinement.php";
frm.submit();
}

function validate_singlerefinement(id)
{
var frm=document.frmdesignerrefinements;
frm.refinementid.value=id;
frm.action="aff_designer_singlerefinement.php";
frm.submit();
}

function doUpdate()
{
  var frm=document.frmviewcart;	 
	var c=0;
  if( frm.frmchanged.value == "1" )
  {
	for(i=0;i<frm.elements.length;i++)
	{
	
     if((frm.elements[i].type == "text"))
	 {
		if(frm.elements[i].value <=0)
		{
			alert(" Quantity Must be  greather than zero");
			return false;
		}
      } // if statement
	if((frm.elements[i].type == "checkbox") && (frm.elements[i].checked == true)) 
		{
				c++;
		} 
	
    } // for l 
if(c == 0)
			{
			alert("Please select Product");
			return false;
			}
		frm.kw.value="Editquantity";
		frm.action = "cartquery.php"; 
		frm.submit();
	} 
	else
	{
		alert("No changes have been made to update.");
		return ;
		
	}
}

function validateaddtocartdeleteproduct()
	{
		var frm = document.frmviewcart;
		var c=0;
		for(i=0;i<frm.elements.length;i++) 
		{
			if((frm.elements[i].type == "checkbox") && (frm.elements[i].checked == true)) 
			{
				c++;
			
			} // if statement
		} // for
	if(c>0)
	{
	if(confirm("Are you sure you want to Delete ?"))
					{
				frm.kw.value="Deleteproduct";
				frm.action="cartquery.php";
				frm.submit();
					}
	
	} 
		if(c == 0)
		{
			alert("Please select Product");
			return false;
		}
 }

function doBuyNow()
{
var frm=document.frmviewcart;
if(frm.checksession.value == "" )
	{
		frm.account.value = "cart";
		frm.action = "d_login.php";
	}
	else if(frm.checksession.value != "")
	{
		frm.action = "d_shipping.php";
	}
	frm.submit();
}

function viewrefinementpopupwindow(url)
	{
		
		var urlname = url;
		var newWin = window.open(urlname,'myChild',"height=200,width=200, menubar=no,resizable=no")
        newWin.focus()
	}

function validatedesignerorders(frm,url,val)
{
	frm.order_type.value=val;
	frm.action=url;
	frm.submit();
}


function validaterating(order_id,productid,url)
{
		var urlname = url+"?order_product_id="+productid+"&orderid="+order_id;
		var newWin = window.open(urlname,'myChild'," height=450,width=600,menubar=no,resizable=no")
        newWin.focus()
}

function funrate(productid,memberid,url)
{
	 var frm=document.frmrating;
	var c=0;
		for(i=0;i<frm.elements.length;i++) 
		{
			if((frm.elements[i].type == "radio") && (frm.elements[i].checked == true)) 
			{
				c++;
			} // if statement
		} // for 
		if(c == 0)
		{
			alert("Please Select the Rate");
			return false;
		}
	 frm.kw.value='RATE';
	 frm.product_id.value=productid;
	 frm.memberid.value=memberid;
	 frm.action=url;
	 frm.submit();
}

function validatedesigntool_refinementrating(refid,memberid)
{
	 var frm=document.frmrating;
	var c=0;
		for(i=0;i<frm.elements.length;i++) 
		{
			if((frm.elements[i].type == "radio") && (frm.elements[i].checked == true)) 
			{
				c++;
			} // if statement
		} // for 
		if(c == 0)
		{
			alert("Please Select the Rate");
			return false;
		}
	 frm.kw.value='RATE';
	 frm.refinement_id.value=refid;
	 frm.memberid.value=memberid;
	 frm.action='designtool_refinementrating.php';
	 frm.submit();
}
function validatedesigner_rating(order_id,productid,url)
{
		var urlname = url+"?order_product_id="+productid+"&orderid="+order_id;
		var newWin = window.open(urlname,'myChild'," height=300,width=400,menubar=no,resizable=no")
        newWin.focus()
}


function validatedesigner_userrating(refid,memberid,url)
{
	 var frm=document.frmrating;
	 frm.kw.value='RATE';
	var c=0;
		for(i=0;i<frm.elements.length;i++) 
		{
			if((frm.elements[i].type == "radio") && (frm.elements[i].checked == true)) 
			{
				c++;
			} // if statement
		} // for 
		if(c == 0)
		{
			alert("Please Select the Rate");
			return false;
		}
	 frm.kw.value='RATE';
	 frm.refinement_id.value=refid;
	 frm.memberid.value=memberid;
	 frm.action=url;
	 frm.submit();
}

function validatedesigntool_usercomments(val,productid,memberid,url)
{
	 var frm=document.frmcomments;
	if(!isValidEntry(frm.subject, "Subject"))
	return false;
	if(!isValidEntry(frm.comments, "Comments"))
	return false;

	 frm.kw.value=val;
	 frm.product_id.value=productid;
	 frm.memberid.value=memberid;
	 frm.action=url;
	 frm.submit();
}

function validateuser_comments(order_id,productid,url)
{
		var urlname = url+"?order_product_id="+productid+"&orderid="+order_id;
		var newWin = window.open(urlname,'myChild'," height=500,width=600,menubar=no,resizable=no")
        newWin.focus()
}

function  validateuserrating(frm,id,url,val)
{
	frm.affid.value=id;
	frm.kw.value=val;
	frm.action=url;
	frm.submit();
}

function validateratingorderdetails(productid,order_id,acturl,val)
{
		var URL=acturl+"?product_id="+productid+"&order_id="+order_id+"&typevalue="+val;
        var newWin = window.open(URL,'myChild',"height=500,width=600,menubar=no,resizable=yes")
        newWin.focus()
}

function validatemonthlyreport(url)
{
	var frm=document.frmreports;
	if(!isValidSelect(frm.mon, "Month"))
	return false;
	if(!isValidSelect(frm.yearly, "Year"))
	return false;
	frm.month.value = frm.mon.options[frm.mon.value].text;
	frm.action=url;
	frm.submit();
}

function validatedailyorderreport(url)
{
	var frm=document.frmreports;
	if(!isValidEntry(frm.startdate, "Start Date"))
	return false;
	if(!isValidEntry(frm.enddate, "End Date"))
	return false;
if((isValidEntry(frm.startdate, "Start Date"))&&(isValidEntry(frm.enddate, "End Date")))
		{
			year1=frm.startdate.value.substr(0,4);
			month1=frm.startdate.value.substr(5,2);
			date1=frm.startdate.value.substr(8,2);
			year=frm.enddate.value.substr(0,4);
			month=frm.enddate.value.substr(5,2);
			date=frm.enddate.value.substr(8,2);
			if((year) < (year1))
			
			{
				alert("start date must be less than end date");
				return false;
			}
			if((year == year1)&&(month < month1))
			{ 
				alert("start date must be less than end date");
				return false;
			}
			if((year == year1)&&(month == month1))
			{
				if(date<date1)
				{
				alert("start date must be less than end date");
				return false;
				}
			
			}		
		}

	frm.action=url;
	frm.submit();
}


function validatestockrepproductdetails(url)
{
	var frm=document.frmstockrepname;
	if(!isValidSelect(frm.category, "Category"))
	return ;
	if(!isValidEntry(frm.itemcode, "Product Code"))
	return ;
	frm.kw.value="searchproductdetails";
	frm.action=url;
	frm.submit();

}


function validatesalesorderentry(url)
{
	var frm=document.frmsalesorderentry;
	if(!isValidEntry(frm.ordercode, "Order Code"))
	return ;
	frm.kw.value="searchorderdetails";
	frm.action=url;
	frm.submit();

}

function validatestockreprefinementdetails(url)
{
	var frm=document.frmstockrepname;
	if(!isValidSelect(frm.category, "Category"))
	return ;
	if(!isValidEntry(frm.itemcode, "Refinement Code"))
	return ;
	frm.kw.value="searchproductdetails";
	frm.action=url;
	frm.submit();

}

function validate_market_product_three()
	{
		var frm = document.frmmproducttwo;
		frm.kw.value="addcategoriestoproduct";
		var c=0;
		for(i=0;i<frm.elements.length;i++) 
		{
			if((frm.elements[i].type == "checkbox") && (frm.elements[i].checked == true)) 
			{
				c++;
			} // if statement
		} // for 
		if(c == 0)
		{
			alert("Please select Category/SubCategory");
			return false;
		}
 }

function validatecontinuelink(frm,url,id)
{
	frm.refinementid.value=id;
	frm.action=url;
	frm.submit();
}

function validate_add_marketproduct()
{
var frm=document.frmaddproduct;
frm.kw.value="addmarketproduct";
if(!isValidEntry(frm.productname,'Product Name'))
	return false;
if(!isValidEntry(frm.productdesc,'Product Description'))
	return false;
if(!isValidEntry(frm.productfrontimage, "Product Front Image"))
	return false;

var productfrontimage=frm.productfrontimage.value;
		if(productfrontimage != "")
			{
				if (!((productfrontimage.substring(productfrontimage.lastIndexOf(".")+1)=="png") || (productfrontimage.substring(productfrontimage.lastIndexOf(".")+1)=="jpeg") || (productfrontimage.substring(productfrontimage.lastIndexOf(".")+1)=="jpg") ||(productfrontimage.substring(productfrontimage.lastIndexOf(".")+1)=="gif") ))
				{
					alert("               Invalid File Format. \n Accepts only  gif or png or jpeg or jpg files with right dimensions only!");
					frm.productfrontimage.focus();
					return false; 
				  }
		   }

}

function validatecontactus_user()
{
 var frm=document.frmcontactus;
	frm.kw.value="send";
if(!isValidEntry(frm.customername, "Name"))
	return false;
if(!isValidEmail(frm.emailaddress,'yes'))
	 return false;
if(!isValidEntry(frm.comments, "Comments"))
	return false;

}

