var	wHandleVkbd = null;
var hCurrentField = null;
var strOrigImage = "";

function winVkbd(hFieldObj) {
   if (wHandleVkbd  && !wHandleVkbd.closed) {
	   wHandleVkbd.close();
	}
   wHandleVkbd = window.open("hebrew.html","","width=420,height=475");
   wHandleVkbd.opener = this;
   hCurrentField = hFieldObj;
  }

function closeVkbd() {
   if (wHandleVkbd)
	  wHandleVkbd.close();
	}	
	
function Validationkeyword(theform)
{
  if (theform.Keyword.value == "" || theform.Keyword.value == "Search Keyword")
  {
    alert("Please enter your search keyword.");
    theform.Keyword.focus();
    return (false);
  }
    return (true);
 } 
 
 function ValidationLogin()
{
  if (frmLogin.uid.value == "" || frmLogin.uid.value == "Username" || frmLogin.pwd.value == "" || frmLogin.pwd.value == "Password")
  {
    alert("Please enter your login username and password.");
    frmLogin.uid.focus();
    return (false);
  }
    return (true);
 } 

function displayWindow(url, width, height) {
      var url1 = 'bigimage.asp?pic=' + escape(url + '&height=' + height + '&width=' + width);
	  var Win = window.open(url1,"",'width=' + (width + 20) + ',height=' + (height + 60) + ',resizable=1,scrollbars=yes,menubar=no,status=no' );
	}

function displayOptionPic(url, width, height) {
      var Win = window.open(url,"",'width=' + (width + 20) + ',height=' + (height + 60) + ',resizable=1,scrollbars=yes,menubar=no,status=no' );
	}
			
function switchImage(sColor,fillsize) {
	var colorpath = 'color/' ;
	var colorPic = ColorMatrix[sColor];
	
    if (sColor != "") {
	   if (document.images.ItemPic) {
		   document.images.ItemPic.src = colorpath + colorPic;
	      }
	   } 
	   
	if (fillsize == 1) {FillSizeList();}    
    }
    
function Validateminorder()
 {                      
   var f = window.document.frmDetail;
   var qty = f.qty.value;
   var strOptionName = "";
   
   if (qty == "")
  {
    alert("Please enter Qty.");
    f.qty.focus();
    return (false);
  }
  
  for(var i=0; i < f.elements.length; i++) {
      var e = f.elements[i];
      
      if (e.type == "select-one" && e.options[e.options.selectedIndex].value =="mustselect") {
         strOptionName = e.options[e.options.selectedIndex].text;
         strOptionName = strOptionName.replace("Choose ", "");
         //alert("You have to choose this option."); 
         alert("Please choose " + strOptionName + ".");
         e.focus();
         return (false);
      }
    }
   
   return (true);
 }
 
 
 function ValidateWholesale()
{
 var f = document.frmRegister;
 
 if (f.Company_name1.value == "")
  {
    alert("Company name is Required.");
    f.Company_name1.focus();
    return (false);
  }
 
 if (f.Conatct_Name1.value == "")
  {
    alert("Conatct Name is Required.");
    f.Conatct_Name1.focus();
    return (false);
  }
 
 if (f.Address_1.value == "")
  {
    alert("Address1 is Required.");
    f.Address_1.focus();
    return (false);
  }
 
 if (f.City1.value == "")
  {
    alert("City is Required.");
    f.City1.focus();
    return (false);
  }  
 
 if (f.State1.options[f.State1.options.selectedIndex].value == "") {
     alert("Please Select State.");
     f.State1.focus();
     return (false);
  }
  
 if (f.Zip_Code1.value == "")
  {
    alert("Zip Code is Required.");
    f.Zip_Code1.focus();
    return (false);
  }  
  
 if (f.Phone1.value == "")
  {
    alert("Phone is Required.");
    f.Phone1.focus();
    return (false);
  }  
 
 if (f.E_mail1.value == "")
  {
    alert("E-mail Address is Required.");
    f.E_mail1.focus();
    return (false);
  }
  
 return (true);
}  

function displaylayer(which) {
    document.getElementById(which).style.display = "block";
    var f = window.document.frmDetail;
    var pt = f.addlogo;
    var i;
    
    for (i=0;i<pt.length;i++){
	    if (pt[i].value=="yes"){
	        pt[i].checked = true;}
     }
  }		
function displaylayer2(which) {
    document.getElementById(which).style.display = "block";
    document.getElementById(which).style.visibility = "visible";
    
  }		
 function hidelayer(which) {
    document.getElementById(which).style.display = "none";
    checkPerson();
  }
  function hidelayer2(which) {
    document.getElementById(which).style.display = "none";
    document.getElementById(which).style.visibility = "hidden";
    
  }  
 
 function hidelayerall() {
    document.getElementById("layerlogo").style.display = "none";
    document.getElementById("layerImprintlogo").style.display = "none";
    document.getElementById("layerpreivew").style.display = "none";
    document.getElementById("layerPerson").style.display = "block";
    
    var f = window.document.frmDetail;
    var pt = f.logo;
    var i;
    
    for (i=0;i<pt.length;i++){pt[i].checked = false;}
  }
  
 function setlogoDisplay(which){
    var f = window.document.frmDetail;
    var pt = f.addlogo;
    var ptype="";
    var i;
    
    for (i=0;i<pt.length;i++){
	   if (pt[i].checked){
		   ptype = pt[i].value;
	    }
     }
    
    if (ptype == "yes"){
        document.getElementById(which).style.display = "none";
        document.getElementById("layerpreivew").style.display = "none";
        checkPerson();}
    else { 
        document.getElementById(which).style.display = "none";
        document.getElementById("layerImprintlogo").style.display = "none";
        document.getElementById("layerpreivew").style.display = "none";
        document.getElementById("layerPerson").style.display = "block";
     }  
}

function checkPerson(){
    var f = window.document.frmDetail;
    var pt = f.logo;
    var ptype="";
    var i;
    
    for (i=0;i<pt.length;i++){
	   if (pt[i].checked){
		   ptype = pt[i].value;
	    }
     }
    
    if (ptype != ""){
        document.getElementById("layerPerson").style.display = "none";
        document.getElementById("layerImprintlogo").style.display = "block";
        if (document.images.Imprintlogo) {document.images.Imprintlogo.src = 'images/' + ptype;}
      }
    else { 
        document.getElementById("layerPerson").style.display = "block";
        document.getElementById("layerImprintlogo").style.display = "none";
     }  
 }


function sColorImage(sColor) {
  if (sColor!="" && sColor!="Choose Color") {
	  var colorPic = ColorMatrix[sColor];
	  
	  if (colorPic!="") {  
	     if (document.images.ItemPic) {
		     document.images.ItemPic.src = 'image.asp?image=color/' + colorPic + '&w=300';
		     //alert(document.getElementById("mItemPic").getAttribute("data-zoomsrc"));
		     document.getElementById("mItemPic").setAttribute("data-zoomsrc","color/" + colorPic);
		     MojoZoom.init();
		     //alert(document.getElementById("mItemPic").getAttribute("data-zoomsrc"));
		     //alert('/image.asp?image=images/' + colorPic + '&w=277');
	       }
	    } 
    } 
   else if(sColor=="Choose Color" && strOrigImage != "")
   {
		if (document.images.ItemPic)
		{
		     document.images.ItemPic.src = 'image.asp?image=images/' + strOrigImage + '&w=300';
		     document.getElementById("mItemPic").setAttribute("data-zoomsrc","images/" + strOrigImage);
		     MojoZoom.init();
		}
   }
 }
 
 function SkipPreivew() { 
   if (Validateminorder()){
       var f = window.document.frmDetail;
       
       if (NoPersoninfo()){
           f.personalno.value = 0;
           f.submit();}
       else {
            if(confirm('Are you sure you want to skip personalization?\nTo personalize press cancel to continue press ok')){
               f.personalno.value = 0;
               f.submit();}
            else {window.location.hash="Personalize";}    
         } 
     }
 }
 
 function preivewDisplay(){
    var f = window.document.frmDetail;
    var addlogo = "";
    var imprintcolor = "";
    var plogo = "";
    var preivew = false;
    var pt = f.addlogo;
    var i;
    
    for (i=0;i<pt.length;i++){
	   if (pt[i].checked){
		   addlogo = pt[i].value;}
       }
    
    if (addlogo == "") {
	    alert("You have to choose ADD A LOGO.");
	    return (false);
     }
    
    pt = f.imprintcolor;
    for (i=0;i<pt.length;i++){
	   if (pt[i].checked){
		   imprintcolor = pt[i].value;}
       }
    
    if (imprintcolor == "") {
	    alert("You have to choose Imprint Color.");
	    return (false);
     }
    
    pt = f.logo;     
    for (i=0;i<pt.length;i++){
	   if (pt[i].checked){
		   plogo = pt[i].value;}
       }
    
    if (plogo != ""){
        preivew = true; }
    else { 
       var person1 = f.person1.value;
       var person2 = f.person2.value;
       var person3 = f.person3.value;
       var person4 = f.person4.value;
       
       if (person1!== "" || person2!== "" || person3!== "" || person4!== ""){
           preivew = true; } 
       else { 
           alert("Please enter your Personalization.");
           f.person1.focus();
           return (false); }  
      }
     
    if (preivew){
        document.getElementById("layerlogo").style.display = "none";
        document.getElementById("layerpreivew").style.display = "block";
        
        if(document.all){
           document.getElementById('disperson1').innerText = f.person1.value;
           document.getElementById('disperson2').innerText = f.person2.value;
           document.getElementById('disperson3').innerText = f.person3.value;
           document.getElementById('disperson4').innerText = f.person4.value; 
           document.getElementById('disperson5').innerText = f.person5.value;
           document.getElementById('disperson6').innerText = f.person6.value;} 
        else{
           document.getElementById('disperson1').textContent = f.person1.value;
           document.getElementById('disperson2').textContent = f.person2.value;
           document.getElementById('disperson3').textContent = f.person3.value;
           document.getElementById('disperson4').textContent = f.person4.value; 
           document.getElementById('disperson5').textContent = f.person5.value;
           document.getElementById('disperson6').textContent = f.person6.value;}

        if (plogo != ""){
            if(document.all){
               document.getElementById('disperson5').innerText = "";
               document.getElementById('disperson6').innerText = ""; } 
            else{
               document.getElementById('disperson5').textContent = "";
               document.getElementById('disperson6').textContent = ""; }
            
            if (document.images.preivewlogo) {
                document.images.preivewlogo.src = 'images/' + plogo;
                document.getElementById("dislogo").style.display = "block";}
           }
         else {document.getElementById("dislogo").style.display = "none";}   
     } 
     
     return (true); 
 }
 
 function NoPersoninfo()
 {                      
   var f = window.document.frmDetail;
   var person1 = f.person1.value;
   var person2 = f.person2.value;
   var person3 = f.person3.value;
   var person4 = f.person4.value;
   var person5 = f.person5.value;
   var person6 = f.person6.value;
   var comments = f.comments.value;
   var imprintcolor = "";
   var plogo = "";
   var pt;
   var i;
   
   if (person1!= "" || person2!= "" || person3!= "" || person4!= "" || person5!= "" || person6!= "" || comments!= ""){
       return (false); } 
  
   pt = f.imprintcolor;
   for (i=0;i<pt.length;i++){
	   if (pt[i].checked){
		   imprintcolor = pt[i].value;}
       }
    
   if (imprintcolor!= "") {return (false);}
   
   pt = f.logo;     
   for (i=0;i<pt.length;i++){
	    if (pt[i].checked){
		    plogo = pt[i].value;}
       }
   
   if (plogo!= "") {return (false);}
       
   return (true);
 }
