/*This script contains most of the javascript functions used for the Westlake Electronic Supply website.
You may use the functions or methods freely, however, keep in mind that not all functions were created 
by myself or specifically for this website.  I have tried to retain credit comments for any functions which I 
have obtained and I hope you do the same.  If you wish to use these in your website be aware of that and
also please link to us on your website or copy and paste this comment into any functions that you wish to use.

http://www.westlake-electronic.com

Thank you,

Joe Easter
IT Manager
Westlake Electronic Supply
800.523.8677

Many tutorials, tips and reference material for the following functions were found at
http://www.w3schools.com/

*/

/* Misc global functions*/

var loginRequired = false;
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };

/* -------------------------------------------------------------------*/
function alternate_units() {
  form = document.forms.product_detail;
  if (form.alt_units) {
    if (!form.alt_units.onchange) form.alt_units.onchange = function () {
      cart_id = document.getElementById('item_id');
      avail = document.getElementById('available');
      avail_display = document.getElementById('available_display');
      price_display = document.getElementById('product_price');
      conversion = this.value.split('|');
      price = conversion[1]; price2 = conversion[2];
      quantity = conversion[0]; weight = conversion[3];
      conv_fac = conversion[4]; conv_index = conversion[5];
      conv_text = conversion[6];
      cart_id_split = cart_id.value.split('|');
      avail.value = quantity; avail_display.innerHTML = quantity;
      cart_id_split[1] = price; price_display.innerHTML = price2;
      cart_id_split[5] = weight; cart_id_split[6] = conv_fac;
      cart_id_split[7] = conv_index; cart_id_split[8] = conv_text;
      cart_id.value = cart_id_split.join('|'); 
      
      //notification(cart_id_split[1]+'|'+avail.value+'|'+avail_display.innerHTML);
      //notification(price+'|'+(avail.value/conversion)+'|'+(avail_display.innerHTML/conversion));
    }
  }
}

/* -------------------------------------------------------------------*/
function blink_box (id) {
  if (document.getElementById) {
    if (document.getElementById(id)) {
      b_blink = 'document.getElementById("'+id+'").style.backgroundColor="#FF0000";document.getElementById("'+id+'").style.color="#FFFFFF"';
      d_blink = 'document.getElementById("'+id+'").style.backgroundColor="";document.getElementById("'+id+'").style.color=""';
      document.getElementById(id).style.backgroundImage='none';
      setTimeout(b_blink,1000);
      setTimeout(d_blink,1500);
      setTimeout(b_blink,2000);
      setTimeout(d_blink,2500);
      setTimeout(b_blink,3000);
      setTimeout(d_blink,5500);
      setTimeout('document.getElementById("'+id+'").style.backgroundImage=""',5500);
    }
  }

}

/* -------------------------------------------------------------------*/
function checkLogin(){

  var Login = getCookie('login');

  if((loginRequired)&&(document.title == "Please Login...")) {
    var STDIN = unescape(location.search.replace(/\+/g,' '));
    STDIN = STDIN.substring(1).split('&');
    for(i=0; i < STDIN.length; i++) STDIN[i] = STDIN[i].split('=');
    var login = STDIN[0][1];
    if(login == "no") alert("Invalid Login. Please Try Again...");
  }

  if((loginRequired)&&(document.title != "Please Login...")){
    if(Login == null) document.location = "cgi-bin/store.php";
    if((Login != null)&&(Login != "true")) document.location = "cgi-bin/store.php";
  }
}

/* -------------------------------------------------------------------*/
function deleteCookie(name) {path="/";domain="www.westlake-electronic.com";if (getCookie(name)) {document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; }}

/* -------------------------------------------------------------------*/
function desc_preview(phase) {
  ef = document.forms.descript_edit;
  function up_d() {
    if (ef.show_desc_preview.checked == true) {
      document.getElementById('descript_preview').style.display='';
      document.getElementById('descript_preview').style.visibility='';
      document.getElementById('descript_preview').innerHTML='<table class="thinborder"><tr><td class="style4"><b>Preview</b>:'+
      '<img alt="Shows automatic text formatting (if any)" name="Shows automatic text formatting (if any)" style="padding-left:20px;" onclick="document.getElementById(\'descript_preview\').innerHTML=text_replace(document.getElementById(\'descript_preview\').innerHTML);" src="/images/refresh.gif" />'+
      '</td><tr><td> ' + ef.description.value + ' </td></tr></table>';
    }
  }
  if (phase==1) {
    if (ef.show_desc_preview.checked == true) up_d();
    else document.getElementById('descript_preview').style.display='none';
  }
  if (phase==3) {
    if (ef.apply_button.disabled == true) ef.apply_button.disabled=false;
    up_d();
  }
}

/* -------------------------------------------------------------------*/
function email_count() {if (document.getElementById("emails")) {the_count = document.getElementById("emails").value.split(",");document.getElementById("total_emails").innerHTML = "<b>Total Emails:</b> " + (the_count.length?the_count.length-1:0);}}

/* -------------------------------------------------------------------*/
function getCookie(name){
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return "";
    }
    else begin += 2;
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) end = dc.length;
    return unescape(dc.substring(begin + prefix.length, end));
}

/* -------------------------------------------------------------------*/
function isEmail(string) {if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) return true; else return false;}

/* -------------------------------------------------------------------*/
function location_array (array_item) {
	var array_item = array_item.toLowerCase();
	var loc_array = window.location.search.toLowerCase().replace("%26","\&");
	var loc_array = loc_array.split("\&"); var loc_val = '';
	for (lc=0; loc_array.length > lc; lc++) {
		if ((loc_array[lc].split("=")[0] == array_item||loc_array[lc].split("=")[0] == "?" + array_item)&&loc_array[lc].split("=")[1] != "") var loc_val = loc_array[lc].split("=")[1];
	}
	return loc_val;
}

/* -------------------------------------------------------------------*/
function lv_pic(id) {if (document.getElementById) {if (id&&document.getElementById(id)) {if (document.getElementById(id).style.display=='') document.getElementById(id).style.display='none'; else document.getElementById(id).style.display='';}}}

/* -------------------------------------------------------------------*/
var n_tim1 = "";
var n_tim2 = "";
function notification(message){
return;
  if (document.getElementById) {
    if (document.getElementById("notification").innerHTML != "") message = document.getElementById("notification").innerHTML + "<br>" + message;
    document.getElementById("notification").innerHTML = message;
    document.getElementById("notification").style.display = "";
    if (n_tim1) clearTimeout(n_tim1);
    n_tim1 = setTimeout("document.getElementById('notification').innerHTML=''",7000);
    if (n_tim2) clearTimeout(n_tim2);
    n_tim2 = setTimeout("document.getElementById('notification').style.display='none'",7000);
  }
}

/* -------------------------------------------------------------------*/
function pick_image (item_id,current) {
	item_id = item_id.toLowerCase();
	graphics_dir = "/images/itempix/";
	if (current == "/images/itempix/nophoto") return current;
  if (current.search(item_id.replace(' ','%20') + "_t") != -1) return graphics_dir + "nophoto";
  return graphics_dir + item_id.replace(' ','%20') + "_t";
}

/* -------------------------------------------------------------------*/
function qtyCheck(form){
  var qtySelected = parseInt(0);

  for(i = 0; i < form.elements.length; i++){
    var fieldName = form.elements[i].name;
    if(fieldName.substring(0,8) == "QUANTITY"){
      var fieldValue = parseInt(form.elements[i].value);
      if(fieldValue > 0){
        qtySelected += parseInt(fieldValue);

        /* Check availability*/

        var id = fieldName.substring(9,fieldName.length);
        var nameFld = "name|" + id;
        var pName = form.elements[nameFld].value.replace(/\s{2,}/g,"");
        
        var option1Fld = "option|1|"+id;
        if (eval(form.elements[option1Fld])) {
          if (!form.elements[option1Fld].selectedIndex) {
            alert("You must choose a selection from the color drop down menu to order \""+pName+"\"!");
            blink_box(option1Fld);
            return false;
          }
        }

        var option2Fld = "option|2|"+id;
        if (eval(form.elements[option2Fld])) {
          if (!form.elements[option2Fld].selectedIndex) {
            alert("You must choose a selection from the size drop down menu to order \""+pName+"\"!");
            blink_box(option2Fld);
            return false;
          }
        }

        var availFld = "available|" + id;
        if(eval(form.elements[availFld])){
          var qtyAvailable = parseInt(form.elements[availFld].value);
          if(fieldValue > qtyAvailable){

            /*if(qtyAvailable <= 0){alert("Sorry, the '" + pName + "' is not available at this time.");}else{//alert("There is only " + qtyAvailable + " of the '" + pName + "' available.\n\n" +//"Please reduce the quantity so it is equal to or below " + qtyAvailable + " item(s).");}form.elements[i].value = "";form.elements[i].focus();return false;*/
            if (qtyAvailable < 0) qtyAvailable = 0;
            var over_amount = fieldValue-qtyAvailable;
            return confirm("Are you sure you would like to place " + over_amount + " of \"" + pName + "\" in back order?  \n\n" + 
            "**PLEASE NOTE** In some cases receiving back order items may take up to 2 weeks (some select items may take longer).  If you place your order with any items that " + 
            "must be back ordered one of our sales representatives will contact you during our business hours (8am to 5pm M-F PST/PDT) " + 
            "with details regarding the back ordered items and will be able to answer any other questions you may have about " + 
            "your order.  If you would like us to ship the items we have separate from the back ordered items tell the sales " +
            "representative who contacts you.");
          }
        }
      }
    }
  }

  if(qtySelected == 0){
    alert("Please enter a quantity of an item to add to the cart.");
    return false;
  }
  return true;
}

/* -------------------------------------------------------------------*/
var kwsug_timer = "";
var kwsug_kw = "";
function search_header (e) {
  df = document.forms; if (!df||!df.search) return;
  kwsug_obj = document.getElementById("kwsug");
  keyw = df.search.keywords;
  if (e) {
    window.location = '/products/all/all/all/all/'+encodeURIComponent(keyw.value)+'/available_only='+df.search.available_only.value;
    searching();
    return false;
  }
  if (typeof keyw.onblur != 'function') {
    keyw.onblur = function () {setTimeout('document.getElementById("kwsug").style.display="none"',100);};
    keyw.onfocus = function () {search_header();if (kwsug_obj&&kwsug_obj.innerHTML) kwsug_obj.style.display="";};
    keyw.onkeyup = function () {search_header();};
    keyw.onmouseover = function () {if (kwsug_obj&&kwsug_obj.innerHTML) kwsug_obj.style.display="";};
    document.onclick = function() {if (kwsug_obj&&kwsug_obj.style.display=="") {setTimeout('document.getElementById("kwsug").style.display="none"',300);} return true; };
		if (!location_array("detail")&&location_array("search")) setCookie("last_page",window.location);
	}
  if (!e) {
    if (df.search.keywords.value == ''||df.search.keywords.value.replace(/[^a-z]/ig,'') == '') {
      if (kwsug_obj) kwsug_obj.style.display="none";
    }
    else {
      if (kwsug_kw != df.search.keywords.value) {
        if (kwsug_timer != "") clearTimeout(kwsug_timer);
        kwsug_timer = setTimeout("ajax_suggest('"+keyw.value.replace(/[^a-z]/ig,'')+"')",200);
        kwsug_kw = keyw.value;
      }
    }
  }
}

/* -------------------------------------------------------------------*/
function searching(){
  if (document.getElementById) {
    if (document.getElementById("searching_display")&&document.getElementById("body_content")) {
      document.getElementById('body_content').style.display='none';
      document.getElementById('searching_display').style.display='';
      document.getElementById('searching_display').style.visibility='';
      document.getElementById('searching_display').innerHTML='<a href="http://www.westlake-electronic.com"><img class="header" style="FILTER:none;width:700px;" title="Back to HomePage" alt="Back to HomePage" src="/images/blank.gif" border="0" /></a>'+
    '<br><br><b>Please wait while we search for your products ...</b><br /><br /><img src="/images/searching3.gif" />';
      window.scrollTo(0,10); window.scrollTo(0,0);
    }
    else {
      if (document.getElementById("search_button")) {
        setTimeout("searching()",1000);
        document.getElementById("search_button").value = "Searching" + document.getElementById("search_button").value.replace("....","").replace("Searching","").replace("Search","") + ".";
      }
    }
  }
  return true;
}

/* -------------------------------------------------------------------*/
function setCookie(name, value, expires, path, domain, secure){var exdate=new Date();exdate.setDate(100);path="/";domain="www.westlake-electronic.com";document.cookie= name + "=" + escape(value) + ((exdate) ? "; expires=" + exdate : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");}

/* -------------------------------------------------------------------*/
function show_hide(id) {
  if (document.getElementById(id).style.display=='none') document.getElementById(id).style.display='';
  else document.getElementById(id).style.display='none';
}


/* -------------------------------------------------------------------*/
function testCookie(){

  var loginCookie = getCookie('login');

  if(loginCookie == null){
    alert("It appears that you do not have cookies turned on in your browser? \n\n" +
    "This web site uses temporary cookies for tracking your purchases " +
    "and you must have cookies enabled to be able to shop on our web site.\n\n" +
    "These temporary cookies are not stored on your computer and will be deleted " +
    "from your browser cache when you close your browser.");
  }
  else{
    if(loginRequired){
      if((loginCookie == null)||(loginCookie == "false")){
        /*document.location = "./cgi-bin/store.php";*/
      }
    }
  }
}

/* -------------------------------------------------------------------*/
function text_replace (text) {
	var text = " " + text.replace(" "," ");
	var colors = " White+FFFFFF\" style=\"background-color:#000000 | Pink+FF0084 | Blue+0000FF | Red+FF0000 | Green+009900 | Purple+9900CC | Orange+FF9900 | Yellow+FFFF00\" style=\"background-color:#000000 | Gold+FFD700\" style=\"background-color:#000000 | Black+000000 | Violet+CC00CC | Brown+996600 | Gray+808080 | Grey+808080";	var colors = colors.split("|");
	color_inc = 0;
	while (colors[color_inc]){
		var color = colors[color_inc].split("+");
		var all_replace = new RegExp("( |\s|\\\W)(" + color[0].replace(" ","") + ")( |\s|\\\W)","ig");
		if (text.search(all_replace) != -1) {
			var hex = color[1].replace(" ","");
			var color = color[0].replace(" ","");
			var text = text.replace(all_replace,"$1<font color=\"#" + hex + "\"><b>$2</b></font>$3");
		}
		color_inc++;
	}
	var text = text.replace(/rainbow/ig,'<b><font color="red">R</font><font color="blue">a</font><font color="green">i</font><font color="yellow" style="background-color:black">n</font><font color="orange">b</font><font color="blue">o</font><font color="purple">w</font></b>');
	var numbers = " Ten-10 | Nine-9 | Eight-8 | Seven-7 | Six-6 | Five-5 | Four-4 | Three-3 | Two-2 | One-1 ";
	var numbers = numbers.split("|");
	number_inc = 0;
	while (numbers[number_inc]){
		var number = numbers[number_inc].split("-");
		var all_replace = new RegExp("( |\\\s|\\\W)(" + number[0].replace(" ","") + ")( |\\\s|\\\W)","ig");
		if (text.search(all_replace) != -1) {
			var word = number[0].replace(" ","");
			var number = number[1].replace(" ","");
			var text = text.replace(all_replace,"$1<b>$2</b> <b>\(" + number + "\)</b>$3");
		}
		number_inc++; 
	}
  
  pname = document.getElementById('product_name').innerHTML.split(' ')[0].split('-');
  pname = pname.slice(1).join('-');
  if (text.search(pname) != -1) {
    all_replace = new RegExp("(\\\s)"+pname+"(\\\s)","ig");
    text = text.replace(all_replace,"$1<strong>" + pname + "</strong>$2");
  }
	return text; 
}

/* -------------------------------------------------------------------*/
function html_switch(temp) {
  if (temp.innerHTML) {
    var html = temp.innerHTML;
    var title = temp.title;
    temp.title = html;
    temp.innerHTML = title;
  }
}
/* -------------------------------------------------------------------*/
function validate_message () {
	document.getElementById("message_type_help").innerHTML=""; document.getElementById("email_address_help").innerHTML=""; document.getElementById("message_content_help").innerHTML="";
	if (!document.forms.contact_us.message_type.value) document.getElementById("message_type_help").innerHTML="<b>&#187;</b> Opps! You forgot to select the <b>type of message</b> this is!";
	if ((!document.forms.contact_us.email_address.value||isEmail(document.forms.contact_us.email_address.value) == false)&&(document.forms.contact_us.message_type.value!="comment")) { document.getElementById("email_address_help").innerHTML="<b>&#187;</b> Opps! You forgot to enter a valid <b>email address</b> for us to reply to!"; return false; }
	if (!document.forms.contact_us.message_content.value) document.getElementById("message_content_help").innerHTML="<b>&#187;</b> Opps! You forgot to enter the <b>message</b>!";
	if (!document.forms.contact_us.message_type.value||!document.forms.contact_us.message_content.value) return false;
}

/*This script was obtained from http://www.instantssl.com 
since it was already accomplishing what I wanted to do with our top menu I slightly modified it to 
add support for our sticky top_menu (#topmenu).  The methods used here by Comodo are much greater
than that of my previous script which moved the #topmenu on scroll event.  It makes brilliant use of the 
IE underscore hack and the expression() CSS attribute.
*/

var Ovr2='';

if (typeof document.compatMode!='undefined'&&document.compatMode!='BackCompat') {
  cot_t1_DOCtp="_top:expression(document.documentElement.scrollTop+document.documentElement.clientHeight-this.clientHeight);_left:expression(document.documentElement.scrollLeft + document.documentElement.clientWidth - offsetWidth);}";
  top_menu_DOCtp="_top:expression(document.documentElement.scrollTop+this.clientHeight-19);_left:0;}";
}
else {
  cot_t1_DOCtp="_top:expression(document.body.scrollTop+document.body.clientHeight-this.clientHeight);_left:expression(document.body.scrollLeft + document.body.clientWidth - offsetWidth);}";
  top_menu_DOCtp="_top:expression(document.body.scrollTop+this.clientHeight-19);_left:0;}";
}
if (typeof document.compatMode!='undefined'&&document.compatMode!='BackCompat') {
  cot_t1_DOCtp2="_top:expression(document.documentElement.scrollTop-20+document.documentElement.clientHeight-this.clientHeight);}";
}
else {
  cot_t1_DOCtp2="_top:expression(document.body.scrollTop-20+document.body.clientHeight-this.clientHeight);}";
}
var cot_bgf0=(window.location.protocol.toLowerCase()=="https:")? "https://secure.comodo.net/trustlogo/images/cot_bgf0.gif" : "http://www.trustlogo.com/images/cot_bgf0.gif";

var cot_tl_bodyCSS='* html {background-color:#FFFFFF;background-image:url('+cot_bgf0+');background-attachment: fixed;background-repeat: repeat;background-position: right bottom;}';
var cot_tl_fixedCSS='#cot_tl_fixed{position:fixed;';
var cot_tl_fixedCSS=cot_tl_fixedCSS+'_position:absolute;';
var cot_tl_fixedCSS=cot_tl_fixedCSS+'bottom:0px;';
var cot_tl_fixedCSS=cot_tl_fixedCSS+'right:0px;';
var cot_tl_fixedCSS=cot_tl_fixedCSS+'clip:rect(0 100 85 0);';
var cot_tl_fixedCSS=cot_tl_fixedCSS+cot_t1_DOCtp;
var cot_tl_popCSS='#cot_tl_pop {background-color: transparent;';
var cot_tl_popCSS=cot_tl_popCSS+'position:fixed;';
var cot_tl_popCSS=cot_tl_popCSS+'_position:absolute;';
var cot_tl_popCSS=cot_tl_popCSS+'height:194px;';
var cot_tl_popCSS=cot_tl_popCSS+'width: 244px;';
var cot_tl_popCSS=cot_tl_popCSS+'right: 120px;';
var cot_tl_popCSS=cot_tl_popCSS+'bottom: 20px;';
var cot_tl_popCSS=cot_tl_popCSS+'overflow: hidden;';
var cot_tl_popCSS=cot_tl_popCSS+'visibility: hidden;';
var cot_tl_popCSS=cot_tl_popCSS+'z-index: 100;';
var cot_tl_popCSS=cot_tl_popCSS+cot_t1_DOCtp2;
var top_menu_fixedCSS='#topmenu {position: fixed;_position: absolute;z-index:998;top:0px;left:0px;';
var top_menu_fixedCSS=top_menu_fixedCSS+top_menu_DOCtp;

document.write('<style type="text/css">'+cot_tl_bodyCSS+cot_tl_fixedCSS+cot_tl_popCSS+top_menu_fixedCSS+'</style>');

function cot_tl_bigPopup(url) {
  newwindow=window.open(url,'name','WIDTH=450,HEIGHT=500,FRAMEBORDER=0,MARGINWIDTH=0,MARGINHEIGHT=0,SCROLLING=no,allowtransparency=true');
  
  if (window.focus) { 
    newwindow.focus()
  }
  return false;
}

function cot_tl_toggleMiniPOPUP_hide(){
  var cred_id='cot_tl_pop';
  var NNtype='hidden';
  var IEtype='hidden';
  var WC3type='hidden';
  
  if (document.getElementById) {
    eval("document.getElementById(cred_id).style.visibility=\""+WC3type+"\"");
  } 
  else {
    if (document.layers) { 
      document.layers[cred_id].visibility=NNtype;
    }
    else { 
      if (document.all) {
        eval("document.all."+cred_id+".style.visibility=\""+IEtype+"\"");
      }
    }
  }
}

function cot_tl_toggleMiniPOPUP_show() {
  cred_id='cot_tl_pop';
  var NNtype='show';
  var IEtype='visible';
  var WC3type='visible';
  
  if (document.getElementById) {
    eval("document.getElementById(cred_id).style.visibility=\""+WC3type+"\"");
  } 
  else { 
    if (document.layers) {
      document.layers[cred_id].visibility=NNtype;
    } 
    else {
      if (document.all) {
        eval("document.all."+cred_id+".style.visibility=\""+IEtype+"\"");
      } 
    }
  }
}

function COT(cot_tl_theLogo,cot_tl_LogoType,LogoPosition,theAffiliate) {
  var cot_tl_myLocation=location.host;
  
  if(window.location.protocol.toLowerCase()=="https:") {
    var cot_tl_miniBaseURL='https://secure.comodo.net/ttb_searcher/trustlogo?v_querytype=C&v_shortname='+cot_tl_LogoType+'&v_search='+cot_tl_myLocation+'&x=6&y=5';
    var cot_tl_bigBaseURL='https://secure.comodo.net/ttb_searcher/trustlogo?v_querytype=W&v_shortname='+cot_tl_LogoType+'&v_search='+cot_tl_myLocation+'&x=6&y=5';
  } 
  else {
    var cot_tl_miniBaseURL='http://www.trustlogo.com/ttb_searcher/trustlogo?v_querytype=C&v_shortname='+cot_tl_LogoType+'&v_search='+cot_tl_myLocation+'&x=6&y=5';
    var cot_tl_bigBaseURL='http://www.trustlogo.com/ttb_searcher/trustlogo?v_querytype=W&v_shortname='+cot_tl_LogoType+'&v_search='+cot_tl_myLocation+'&x=6&y=5';
  };
  document.write('<div id="cot_tl_pop">');
  document.write('<IFRAME src="'+cot_tl_miniBaseURL+'" WIDTH=244 HEIGHT=194 FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no allowtransparency=true></IFRAME>');
  document.write('</div>');
  document.write('<div id="cot_tl_fixed">');
  document.write('<a href="http://www.instantssl.com" onClick="return cot_tl_bigPopup(\''+cot_tl_bigBaseURL+'\')"><img src='+cot_tl_theLogo+' alt="SSL Certificate" border="0" onMouseOver="Ovr=setTimeout(\'cot_tl_toggleMiniPOPUP_show()\',1000);clearTimeout(Ovr2)" onMouseOut="Ovr2=setTimeout(\'cot_tl_toggleMiniPOPUP_hide()\',4000);clearTimeout(Ovr)"</a>');
  document.write('</div>');
}



 // CP Realtime order form javascripts

 // These javascripts are used to validate
 // entries in the form fields and also to
 // save the user data in a cookie

 // The first two functions below are where
 // you would set the field names should you
 // need to add some to the list(s).

 // 1. function requiredFields() validates that the
 //    entries are filled in when the form is
 //    submitted.

 // 2. function saveUserInfo() sets a single cookie for each
 //    that contains all of the information in all of the form
 //    fields used in the orderform. There is also a list of
 //    fields that are NOT saved when this function is executed.
 //    You can add to this list as needed.

 // All remaining functions below are basically private
 // functions used by the main 2 functions above.


// -------------------------------------------------------------------
function requiredFields(type,form){

     // Setup an array of the required
     // form field names to validate:

 var requiredFields = new Array("Billing_Name",
                                "Billing_Address",
                                "Billing_City",
                                "Billing_State",
                                "Billing_Zip",
                                "Billing_Phone",
                                "Email_Address");

 var len = requiredFields.length -1;

     // Add appropriate fields for
     // credit cards and checks

 if(type == "credit_card"){
     requiredFields[len + 1] = "Card_Number";
     requiredFields[len + 2] = "Name_On_Card";
     requiredFields[len + 3] = "Expire_Month";
     requiredFields[len + 3] = "Expire_Year";
 }
 if(type == "check"){
     requiredFields[len + 1] = "Bank_Name";
     requiredFields[len + 2] = "Name_On_Account";
     requiredFields[len + 3] = "Account_Number";
     requiredFields[len + 4] = "ABA_Routing_Code";
 }
 if(type == "po"){
     requiredFields[len + 1] = "PO_Number";
 }

     // Loop through the form fields and
     // test each of the required fields

     for(j = 0; j < requiredFields.length; j++){
          var requiredField = form.elements[requiredFields[j]].value;
          if(requiredField == ""){
            var label = "";
            for (i=0; i < requiredFields[j].length; i++) {
              character = requiredFields[j].charAt(i);
              if ("_".indexOf(character) != -1){
                   label += " ";
              }
              else{
                   label += character;
              }
            }
            form.elements[requiredFields[j]].focus();
            form.elements[requiredFields[j]].select();
            alert("You forgot to fill in the \"" + label + "\" field.\n" +
                 "This field is required before processing your order.");
            return false;
          }
          
          if (requiredFields[j] == "Email_Address"){
            if (!isEmail(requiredField)) {
              alert("The E-Mail address you provided was invalid.  Please try again");
              form.elements[requiredFields[j]].focus();
              form.elements[requiredFields[j]].select();
              return false;
            }
          }

          if(requiredFields[j] == "Billing_Phone"){
               if(requiredField != ""){
                    var cleanPhone = strip(requiredField);
                    form.elements[requiredFields[j]].value = cleanPhone;
                    if (!cleanPhone) j--;
               }
          }


     }
return true;
};

// -------------------------------------------------------------------
/*function saveUserInfo(type,formName){

     // This function saves the data from the
     // orderform in a single cookie called
     // "userInfo". This cookie is saved in
     // HEX format so that it makes it much
     // harder to read.

     // This is a list of credit card and
     // check fields that are NOT saved to
     // cookies

var notSaved = new Array();

if(type == "credit_card"){
     notSaved[0] = "Name_On_Card";
     notSaved[1] = "Card_Number";
     notSaved[2] = "Expire_Month";
     notSaved[3] = "Expire_Year";
}
if(type == "check"){
     notSaved[0] = "Bank_Name";
     notSaved[1] = "Account_Number";
     notSaved[2] = "Name_On_Account";
     notSaved[3] = "ABA_Routing_Code";
}
if(type == "po"){
     notSaved[0] = "PO_Number";
}

     // create and set the hex encrypted
     // userInfo cookie

 var userCookie = "";

 for(i = 0; i < document.forms[formName].elements.length; i++){
     var inType = document.forms[formName].elements[i].type;
     if(inType == "text"){
        var cookieName = document.forms[formName].elements[i].name;
        var cookieValue = document.forms[formName].elements[i].value;
        var cookieLen = cookieValue.length;

        // Set cookies if they are not credit card fields
        // We set those fields blank.

        for(j = 0; j < notSaved.length; j++){
          if(cookieName == notSaved[j]){
               cookieValue = "";
               break;
          }
        }
        if(cookieValue != ""){

          // Replace the colons, equal signs and commas
          // so they don't screw with the cookie.

          var strippedValue = "";
          for (k=0; k < cookieValue.length; k++) {
               var character = cookieValue.charAt(k);
               if((character == ":")||
                  (character == "=")||
                  (character == ",")||
                  (character == "+")){
                    character = " ";
               }
               strippedValue += character;
          }

               // create the cookie

          if(userCookie == ""){
               userCookie += cookieName + "=" + strippedValue;
          }
          else{
               userCookie += ":" + cookieName + "=" + strippedValue;
          }
        }
     }
   }

     // Convert to hex and write the cookie

var encStr = str2hex(escape(userCookie));
setCookie('userInfo',encStr);
};*/

// -------------------------------------------------------------------
function checkRequiredFields(type,form){

     // Checks to make sure the various
     // form fields are filled in

     // First check the required fields

     var Required = requiredFields(type,form);
     if(Required != true){
          return false;
     }

     if(type == "credit_card"){

          // Then the payment fields
          // Comment (//) these next to lines for testing:

          var Payment = checkCard(form);
          if(!Payment){
               return false;
          }

          var Expire = checkExpireDate(form);
          if(!Expire) return false;

     }
     else{
          return true;
     }
};

// -------------------------------------------------------------------
function mstatus (stat) {
  oform = document.forms.order;
  if (oform.Mailing_Name.disabled==1||oform.Mailing_Name.disabled==0) {
    if (stat==1) stat=0;
    else stat=1;
    oform.Mailing_Name.disabled=stat;
    oform.Mailing_Address.disabled=stat;
    oform.Mailing_Address2.disabled=stat;
    oform.Mailing_City.disabled=stat;
    oform.Mailing_State.disabled=stat;
    oform.Mailing_Zip.disabled=stat;
    oform.Mailing_Country.disabled=stat;
  }
};

// -------------------------------------------------------------------
function msubmit () {
  oform = document.forms.order;
  if (oform.mbdiff.checked==0||!oform.Mailing_Zip.value) {
    oform.Mailing_Name.value=oform.Billing_Name.value;oform.Mailing_Name.disabled=0;
    oform.Mailing_Address.value=oform.Billing_Address.value;oform.Mailing_Address.disabled=0;
    oform.Mailing_Address2.value=oform.Billing_Address2.value;oform.Mailing_Address2.disabled=0;
    oform.Mailing_City.value=oform.Billing_City.value;oform.Mailing_City.disabled=0;
    oform.Mailing_State.value=oform.Billing_State.value;oform.Mailing_State.disabled=0;
    oform.Mailing_Zip.value=oform.Billing_Zip.value;oform.Mailing_Zip.disabled=0;
    oform.Mailing_Country.value=oform.Billing_Country.value;oform.Mailing_Country.disabled=0;
  }
  return true;
};

// -------------------------------------------------------------------
function formFill2 () {
  oform = document.forms.order;
  if (oform.Billing_Name.value.search(/WebGuest/i) != -1) oform.Billing_Name.value = "";
  if (oform.Billing_Country.value == "") {
  notification('one');
  //oform.Billing_Country.value = location_array("Mailing_Country").toUpperCase();
  }
  if (oform.Mailing_Zip.value.length > 3) {oform.mbdiff.checked=true;mstatus(1);}
  else {oform.mbdiff.checked=false;mstatus(0);}
};

// -------------------------------------------------------------------
function isCreditCard(st) {

     // Tests the credit card number.
     // Encoding only works on cards
     // with less than 19 digits

     if (st.length > 19)
          return (false);
     sum = 0; mul = 1; l = st.length;
     for (i = 0; i < l; i++) {
          digit = st.substring(l-i-1,l-i);
          tproduct = parseInt(digit ,10)*mul;
          if (tproduct >= 10)
               sum += (tproduct % 10) + 1;
          else
               sum += tproduct;
          if (mul == 1)
               mul++;
          else
               mul--;
     }
     if ((sum % 10) == 0)
          return (true);
     else
          return (false);
};
// -------------------------------------------------------------------
function strip(val) {

     // Strips the dashes, spaces, etc
     // from the credit card number

val = "" + val;
     if (!val)
          return "";
     var result = "";
     for (i=0; i < val.length; i++) {
          character = val.charAt(i);
          if ("0123456789".indexOf(character) != -1)
          result += character;
     }
return result;
};
// -------------------------------------------------------------------
function checkCard(form){

     // Checks the credit card field for
     // empty and invalid card entries

     var cardNumField = "Card_Number";

     var cardField = form.elements[cardNumField];
     var entry = form.elements[cardNumField].value;
     if(entry == ""){
          alert('You did not enter a valid credit card number\n' +
               'Please check your entry and try again.');
          cardField.focus();
          return false;
     }
     var strippedEntry = strip(entry);
     if((!isCreditCard(strippedEntry))||(strippedEntry.length == 0)){
          alert('The credit card number you entered could not be validated.\n' +
                'Please check the number and try again.');
          cardField.focus();
          cardField.select();
          return false;
     }
return true;
};

// -------------------------------------------------------------------
function checkExpireDate(form) {

     // make sure the date is in the future
     var expireMonth = form.elements['Expire_Month'].value-1;
     var expireYear = "20" + form.elements['Expire_Year'].value;
     var today = new Date();
	 if (today.getMonth() > expireMonth&&today.getFullYear() >= expireYear) {
          alert("The expiration date you entered is invalid.\n\n" +
                "Please enter a valid expiration date for the credit card.");
          form.elements['Expire_Month'].focus();
          return false;
     }

return true;
};

function card_type(){
  if (document.forms.order.Card_Number.value) {
    //Let's keep it clean!
    document.forms.order.Card_Number.value=document.forms.order.Card_Number.value.replace(/\D/ig,"");
    card_number = document.forms.order.Card_Number.value;
    if (card_number.length == 16) document.forms.order.Expire_Month.focus();
    if (card_number.substr(0,1).search(/(3|4|5|6)/ig) == 0&&card_number.length==1) 
    document.getElementById("credit_card_type").selectedIndex = card_number.substr(0,1).replace(3,3).replace(4,0).replace(5,1).replace(6,2);
  }
};

/*Foundation functions and reference found at 
http://www.w3schools.com/
*/

var aj_hist = new Array();

function ajax_setup(fun) {
return;
  x = document.links;
  for (i = 0;i<x.length;i++) {
    if (!x[i].onclick&&
        (x[i].href.charAt(0)=="/"||x[i].href.search('www.westlake-electronic.com')!=-1)&&
        !x[i].target&&x[i].href.search('.pdf')==-1) x[i].onclick=ajax_get;
  }
}
function ajax_control() {
//return;
  if (document.getElementById) {
    if (document.getElementById('aj_cont')) {
      document.getElementById('aj_cont').style.display='';
      document.getElementById('aj_cont').innerHTML='AJAX Control coming soon!</div>'
    }
  }
}
function ajax_history(what) {

  if (what=='count') return aj_hist.length;
  if (what=='list') {
  
    return;
  }
  if (what=='last') what = 0;
  if (what=='first') what = aj_hist.length-1;
  if (what=='off') {
    url='';
    if (aj_hist.length >=1) url = aj_hist[0];
    if (url) url = url.split('|')[0].replace('&ajax=1','').replace('?ajax=1','');
    if (aj_hist.length >= 1&&url) window.location=url;
    else {notification('No AJAX History Found.'); window.location=window.location;}
  }
  if (what >= 0) {
    if (aj_hist.length-1>=what) window.location=aj_hist[what].split('|')[0];
    else notification('AJAX History Error.');
  }
  else {
    aj_hist.reverse();
    aj_hist[aj_hist.length]=what;
    aj_hist.reverse();
  }
  
}
function ajax_suggest(str) {
//return;
  if (str.length >= 1&&document.getElementById("kwsug")) {
    str = 'http://www.westlake-electronic.com/search_stats.php?kw='+str;
    var url = str+(str.indexOf('?')!=-1?'&':'?')+'ajax=1';
    if (window.location.protocol == 'https:') url = url.replace(/^http:/,'https:');
    xmlHttp=GetXmlHttpObject(stateChanged);
    if (!xmlHttp) return;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
  }
}
function ajax_get_url(str) {
  if (str.length > 0) {
    str=str.split('#');
    var url = str[0]+(str[0].indexOf('?')!=-1?'&':'?')+'ajax=1'+(str.length==2?'#'+str[1]:'');
    if (window.location.protocol == 'https:') url = url.replace(/^http:/,'https:');
    xmlHttp=GetXmlHttpObject(stateChanged);
    if (!xmlHttp) return;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    document.getElementById('content_area').innerHTML='<div id="ajax_load">'+
                                                      ' <img src="/images/searching7.gif" alt="" /></div>'+
                                                      document.getElementById('content_area').innerHTML;
    ajax_history(url+'|'+this.innerHTML);
  }
}
function ajax_get() {
  str = this.href;
  if (!str) {notification('Sorry, this link is not yet AJAX capable.  You\'ll have to disable AJAX to use it.');return;}
  if (!document.getElementById) return;
  if (!document.getElementById('content_area')) return;
  if (str.length > 0) {
    str=str.split('#');
    var url = str[0]+(str[0].indexOf('?')!=-1?'&':'?')+'ajax=1'+(str.length==2?'#'+str[1]:'');
    if (window.location.protocol == 'https:') url = url.replace(/^http:/,'https:');
    xmlHttp=GetXmlHttpObject(stateChanged);
    if (!xmlHttp) return;
    xmlHttp.open("POST",url,true);
    xmlHttp.send(null);
    window.scrollTo(0,0);
    document.getElementById('content_area').innerHTML='<div id="ajax_load">'+
                                                      ' <img src="/images/searching7.gif" alt="" /></div>'+
                                                      document.getElementById('content_area').innerHTML;
    ajax_history(url+'|'+this.innerHTML);
    return false;
  }
}

function stateChanged() { 
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
    if (xmlHttp.responseText) {
      response = xmlHttp.responseText;
      if (response.search(/<keyword_suggest>/) != -1) {
        if (document.forms.search.keywords.value=='') return;
        response = response.replace(/<keyword_suggest>|<\/keyword_suggest>/,'');
        if (response.search(/href/) != -1) {
          document.getElementById("kwsug").innerHTML=response;
          document.getElementById("kwsug").style.display="";
        }
        else {
          document.getElementById("kwsug").innerHTML="";
          document.getElementById("kwsug").style.display="none";
        }
      }
      else {
        response=response.split('<!--RECENT!-->');
        document.getElementById("content_area").innerHTML=response[0];
        if (response.length >= 2) document.getElementById("panel_7_c").innerHTML=response[1];
        if (response.length >= 3) document.getElementById("content_area").innerHTML+=response[2];
        if (xmlHttp.responseText.search("panel_")!=-1) setup_mp();
        ajax_setup('run');ajax_control();
      }
    }
    //else {notification('No Content, redirecting...'); ajax_history('off');}
  }
} 

function GetXmlHttpObject(handler) { 
  var objXmlHttp=null;

  if (navigator.userAgent.indexOf("Opera")>=0) {
    //alert("This example doesn't work in Opera");
    return false;
  }
  if (navigator.userAgent.indexOf("MSIE")>=0) {
    var strName="Msxml2.XMLHTTP";
    if (navigator.appVersion.indexOf("MSIE 5.5")>=0) {
      strName="Microsoft.XMLHTTP";
    } 
    try { 
      objXmlHttp=new ActiveXObject(strName);
      objXmlHttp.onreadystatechange=handler;
      return objXmlHttp;
    } 
    catch(e) { 
      //alert("Error. Scripting for ActiveX might be disabled") 
      return false;
    } 
  } 
  if (navigator.userAgent.indexOf("Mozilla")>=0) {
    objXmlHttp=new XMLHttpRequest();
    objXmlHttp.onload=handler;
    objXmlHttp.onerror=handler;
    return objXmlHttp;
  }
  return false;
}

/* FoldoutMenu Copyright (C) 2001 <a href="/dhtmlcentral/thomas_brattli.asp">Thomas Brattli</a> This script was released at 
DHTMLCentral.com Visit for more great scripts! This may be used and changed freely as long as this msg is intact! We will also appreciate 
any links you could give us. Made by Thomas Brattli 

This has been heavily modified from the original and turned into a single object
-Joseph Easter 11.13.09
*/ 
product_menu = {
  FoldNumber: Categories.length,
  stayFolded: false,
  oSub: [],
  browser: function (){ 
    this.ver = navigator.appVersion,
    this.agent = navigator.userAgent, 
    this.dom = document.getElementById?1:0,
    this.opera5 = this.agent.indexOf("Opera 5")>-1,
    this.ie = (this.ver.search(/MSIE [1-9]/i)>-1&&this.dom&&!this.opera5?1:0),
    this.mac = this.agent.indexOf("Mac")>-1,
    this.ns6 = (this.dom && parseInt(this.ver) >= 5) ?1:0,
    this.ns4 = (document.layers && !this.dom)?1:0,
    this.opera5 = (navigator.userAgent.indexOf("Opera")>-1 && document.getElementById)?true:false;
    if (this.opera5) this.bw.ns6 = 0;
    this.bw = (this.ie || this.ns4 || this.ns6 || this.opera5)
  },
  hover_io: function (el) {if (el.style.backgroundColor == '') el.style.backgroundColor='#CCCCCC'; else el.style.backgroundColor='';},
  makeMenu: function(num,depth){ 
    mm = {};
    if (depth == 0) obj= 'divSub'+num;
    if (depth == 1) obj= 'divMfc'+num;
    mm.el= document.getElementById(obj);
    mm.p = {};
    if (typeof mm.el == 'undefined') return; 
    if (depth == 0) {
      mm.p.el = document.getElementById(obj).parentNode;
      mm.p.mouse_func = function () {product_menu.menu(num,-1);product_menu.hover_io(this);};
      mm.p.el.onmouseover=mm.p.mouse_func;
      mm.p.el.onmouseout=mm.p.mouse_func;
      if (mm.p.el&&mm.p.el.style) fix_jserror = mm.p.el.style; 
      else fix_jserror = '';
      mm.css= this.ns4?mm.p.el:fix_jserror; 
    }
    if (depth == 1) {
      mm.p.el = document.getElementById(obj).parentNode;
      mm.p.mouse_func = function () {num2 = this.parentNode.id.replace('divSub','');product_menu.menu(num,num2);product_menu.hover_io(this);};
      mm.p.el.onmouseover=mm.p.mouse_func;
      mm.p.el.onmouseout=mm.p.mouse_func;
      if (mm.p.el&&mm.p.el.style) fix_jserror = mm.p.el.style; 
      else fix_jserror = '';
      mm.css= this.ns4?mm.p.el:fix_jserror; 
    }

    if (mm.el&&mm.el.style) fix_jserror = mm.el.style; 
    else fix_jserror = '';
    mm.id= obj;
    mm.css= this.ns4?mm.el:fix_jserror; 
    mm.ref= this.ns4?mm.el.document:document; 
    mm.x= (this.ns4||this.opera5)?mm.css.left:mm.el.offsetLeft; 
    mm.y= (this.ns4||this.opera5)?mm.css.top:mm.el.offsetTop; 
    mm.h= (this.ie||this.ns6)?mm.el.offsetHeight:this.ns4?mm.ref.height:this.opera5?mm.css.pixelHeight:0;
    mm.vis= function(){if(this.css.visibility=='hidden'||this.css.visibility=='HIDDEN'|| this.css.visibility=='hide'||this.css.display=='none') return false;else return true;};
    mm.hideIt= function(){this.css.display='none';};
    mm.showIt= function(){this.css.display='';};
    return mm;
  },
  /*This is the function that changes the sub menus to folded or unfolded state.*/ 
  menu: function(num,num2){ 
    if (typeof this.oSub == 'undefined') return;
    if (this.oSub.length<=num) return;
    if(this.bw){
      if (!this.stayFolded) {
        for (var i=0; i<this.oSub.length; i++) {
          if (i!=num&&i!=num2&&this.oSub[i].vis()&&num==-1) this.oSub[i].hideIt();
        }
      }
      if (this.oSub[num]) {
        if (!this.oSub[num].vis()) this.oSub[num].showIt();
        else this.oSub[num].hideIt();
      }
    }
  },
  catDescript2url: function (desc) {
    return desc.trim().replace(/[^.0-9a-z]/gi,'-').replace(/-{2,}/g,'-').replace(/-$/,'');
  },
  init: function(){
    this.browser();
    createCategories();
    if (document.getElementById) { 
      if (document.getElementById('divCont')) {
        //Setup some vars
        div = function () {return document.createElement('div');};
        prod_div = document.getElementById('divCont'); 
        O_url = "/products";
        stvar=0;offset = 18;this.sFoldNumber = this.FoldNumber-1;
        sub_onclick = function () {searching()};
        
        //Go through the categories
        for (catCount=0;catCount<Categories.length;catCount++) {
          //Set the category description and add to the search URL.
          catdescript = Categories[catCount][0].split("|"); 
          C_url = O_url+(catdescript[1]?'/'+this.catDescript2url(catdescript[1]):'');
                    
          //Set the dynamic top position based on the number of subcategories in a category so the menu can fit better vertically
          bottom = Categories[catCount].length*offset+stvar;
          if (bottom > Categories.length*offset) stvar_change = stvar-Math.round((bottom-stvar)/2);
          else stvar_change = stvar;
          if (stvar_change <= -80) stvar_change = -80;
          //if (stvar_change <= 0) stvar_change = 1;
          
          //Create the top div for the category name and the sub div for the sub categories
          topDiv = div(); 
          topDiv.style.width='100%';
          topDiv.className='clTop';
          topDiv.innerHTML = '<a><strong>'+catdescript[1]+'</strong></a>';
          subDiv = div(); 
          subDiv.className='clSub';
          subDiv.style.display='none';
          subDiv.style.top=(stvar_change?stvar_change:stvar)+'px';
          subDiv.id = 'divSub'+catCount;
          stvar += offset;
          
          //Go through the sub categories
          for (scatCount=1;scatCount<Categories[catCount].length;scatCount++) {
            //If the subcategory is an array then we need to setup a submenu for it as well.
            if (typeof Categories[catCount][scatCount] != 'string') {
              this.sFoldNumber++;
              //Set the description and add to the search URL
              scatdescript = Categories[catCount][scatCount][0].split("|");
              S_url = C_url+'/' + this.catDescript2url(scatdescript[1]);
              if (scatdescript[0].search('-') != -1) scatdescript[1] = '<em>'+scatdescript[1]+'</em>';
              else scatdescript[1] = '<b>'+scatdescript[1]+'</b>';
              
              //Create the sub 
              tempDiv = div(); 
              tempDiv.style.width="100%";
              
              mfcDiv = div();
              mfcDiv.id = 'divMfc'+this.sFoldNumber;
              mfcDiv.className = 'clMfc';
              mfcDiv.style.display = 'none';

              for (mcatCount=1;mcatCount<Categories[catCount][scatCount].length;mcatCount++) {
                mcatdescript = Categories[catCount][scatCount][mcatCount].split("|");
                M_url = S_url+'/'+this.catDescript2url(mcatdescript[1]);
                mfcDiv.innerHTML += '<a '+sub_onclick+' href="'+M_url+'">'+mcatdescript[1]+'</a><br />';
              }
              tempDiv.appendChild(mfcDiv);
              tempDiv.innerHTML += '<a style="clear:both" '+sub_onclick+' href="'+S_url+'">'+scatdescript[1]+'</a><br />';
              subDiv.appendChild(tempDiv);
            }
            else {
              scatdescript = Categories[catCount][scatCount].split("|");
              S_url = C_url+'/' + this.catDescript2url(scatdescript[1]);
              if (scatdescript[0].search('-') != -1) scatdescript[1] = '<em>'+scatdescript[1]+'</em>';
              else scatdescript[1] = '<b>'+scatdescript[1]+'</b>';
              subDiv.innerHTML += '<a style="clear:both;width:100%" '+sub_onclick+' href="'+S_url+'">'+scatdescript[1]+'</a><br />';
            }
            topDiv.appendChild(subDiv);
          }
          prod_div.appendChild(topDiv);
        }
        if (this.bw) { 
          for (var i=0; i<this.FoldNumber; i++) this.oSub[i] = this.makeMenu(i,0);
          for (var i=this.FoldNumber; i<=this.sFoldNumber; i++) this.oSub[i] = this.makeMenu(i,1);
        }
      }
    }
  }
}