var	wHandleVkbd = null;
var hCurrentField = null;

function winVkbd(hFieldObj) {
   if (wHandleVkbd  && !wHandleVkbd.closed) {
	   wHandleVkbd.close();
	}
   wHandleVkbd = window.open("hebrew.html","","width=390,height=375");
   wHandleVkbd.opener = this;
   hCurrentField = hFieldObj;
  }

function closeVkbd() {
   if (wHandleVkbd)
	  wHandleVkbd.close();
	}
	
function Validationkeyword(theform)
{
  if (theform.Keyword.value == "")
  {
    alert("Please enter your search keyword.");
    theform.Keyword.focus();
    return (false);
  }
    return (true);
 } 
 
 function ValidationLogin()
{
  if (frmLogin.uid.value == "")
  {
    alert("Please enter your login username.");
    frmLogin.uid.focus();
    return (false);
  }
  
  if (frmLogin.pwd.value == "")
  {
    alert("Please enter your password.");
    frmLogin.pwd.focus();
    return (false);
  }
  
    return (true);
 } 

function displayWindow(url, width, height) {
      var url1 = 'bigimage.asp?pic=' + url + '&height=450&width=450';
	  var Win = window.open(url1,"",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=no' );
	}
		
function FillSizeList() {
var mfr = document.frmDetail.color;
var model = document.frmDetail.size;
var ml = ColorList[mfr.options[mfr.selectedIndex].text];
for (var i=model.length; i >= 0; i--){
	model.options[i] = null;
  }
for (var i=0; i < ml.length; i++){
	model.options[i] = new Option(ml[i]);
  }
}


function switchImage(sColor,fillsize) {
	var colorpath = 'images/' ;
	var colorPic = ColorMatrix[sColor];
	
    if (sColor != "") {
	   if (document.images.ItemPic) {
		   document.images.ItemPic.src = colorpath + colorPic;
	      }
	   } 
	  
	if (fillsize == "1") {FillSizeList();}
  }
    
function ValidateSelection(opt)
 {                      
   var f = window.document.frmDetail;
   
   for(var i=0; i < f.elements.length; i++) {
      var e = f.elements[i];
      
      if (e.type == "select-one") {
         if (e.name == "size" && (e.options[e.options.selectedIndex].text =="" || e.options[e.options.selectedIndex].text =="Please Select Size")) { 
            alert("Please choose size.");
            e.focus();
            return (false);
         }
         
         if (e.name == "color" && e.options[e.options.selectedIndex].value =="") { 
            alert("Please choose color.");
            e.focus();
            return (false);
         }
         
         if (e.options[e.options.selectedIndex].value =="" && e.name != "size" && e.name != "color") { 
            alert("Please choose options.");
            e.focus();
            return (false);
         }
      }
   }
 
 var itemname = f.itemname.value;
 
 if (opt == 1) { 
    var color = f.color.options[f.color.options.selectedIndex].text;
    var size = f.size.options[f.size.options.selectedIndex].text;
 
    if (color != "") {
       itemname = itemname + "  color: " + color;
    }
 
    if (size != "") {
       var sizeCode  = size.split(" --- ");

       itemname = itemname + "  size: " + sizeCode[0];
       f.price.value = sizeCode[1];
       
       if (sizeCode.length == 3) {
          f.weight.value = sizeCode[2];
        }  
    }
  }
 
 else if (opt == 2) { 
     var color = f.color.options[f.color.options.selectedIndex].text;
     
     if (color != "") {
       itemname = itemname + "  color: " + color;
     } 
  }
 
 else if (opt == 3) { 
     var size = f.size.options[f.size.options.selectedIndex].value;
     
     if (size != "") {
       var sizeCode  = size.split(" --- ");

       itemname = itemname + "  size: " + sizeCode[0];
       f.price.value = sizeCode[1];
       
       if (sizeCode.length == 3) {
          f.weight.value = sizeCode[2];
        }  
     }
  }
     
 f.item.value = itemname;    
 return (true);
 }
 
function emailcheck(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 Address");
	  return false;
   }

  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
     alert("Invalid E-mail Address");
	 return false;
   }

   if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	   alert("Invalid E-mail Address");
	   return false;
    }

    if (str.indexOf(at,(lat+1))!=-1){
	   alert("Invalid E-mail Address");
	   return false;
     }

    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	   alert("Invalid E-mail Address");
	   return false;
     }

    if (str.indexOf(dot,(lat+2))==-1){
	   alert("Invalid E-mail Address");
	   return false;
     }
		
    if (str.indexOf(" ")!=-1){
	   alert("Invalid E-mail Address");
	   return false;
     }

    return true;					
   }
   
function ValidateFeedback(){
    var f = document.frmFeedback;
	var email = f.Email;
	
	if (f.FirstName.value == ""){
       alert("Please enter your first name");
       f.FirstName.focus();
       return (false);
     }
    
    if (f.LastName.value == ""){
       alert("Please enter your last name");
       f.LastName.focus();
       return (false);
     }
     
	if ((email.value==null)||(email.value=="")){
		alert("Please enter your e-mail address");
		email.focus();
		return false;
	 }
	
	if (emailcheck(email.value)==false){
		email.value="";
		email.focus();
		return false;
	 }
	
	return true;
 }   