<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}



//-->


function inputCustomInfo(frm) {
   var prefix0 = 'get_';
   var input_array = new Array('address','city','zip_code');
   var error_array = new Array('an Address','a city','a valid zip code');

   if (frm.elements['get_first_name'].value.length == 0) {
      alert('Please enter your first name');
      frm.elements['get_first_name'].focus();
      return false;
   }

   if (frm.elements['get_last_name'].value.length == 0) {
      alert('Please enter your last name');
      frm.elements['get_last_name'].focus();
      return false;
   }

   if (!(validEmail(frm.elements['get_email'].value))) { 
      alert('Please enter a valid email address in the form of email@host.tag.');
      frm.elements['get_email'].focus();
      return false;
   }

   if (frm.elements['get_password_1'].value.length == 0) {
      alert('Please enter a password 6-10 characters long using only letters or numbers.');
      frm.elements['get_password_1'].focus();
      return false;
   }

   if (frm.elements['get_password_2'].value.length == 0) {
      alert('Please confirm Password.');
      frm.elements['get_password_2'].focus();
      return false;
   }

   if (frm.elements['get_password_1'].value != frm.elements['get_password_2'].value) {
      alert('Your password confirmation does not match the original password');
      frm.elements['get_password_2'].focus();
      return false;
   }

   for (var i=0; i<input_array.length; i++) {
      var source = prefix0+input_array[i];          
      if (frm.elements[source].value.length == 0) {
         alert('Please enter '+error_array[i]);
         frm.elements[source].focus();
         return false;
      }
   }

   if (frm.elements['get_zip_code'].value) {
      myreg = new RegExp("^\\d{5}$");
      res = myreg.test(frm.elements['get_zip_code'].value);
      if (!res) {
         alert('Please enter a valid zip code');
         frm.elements['get_zip_code'].focus(); 
         return false;
      }
   }

   
   return true;
}
function inputSize(frm){
 ref_size = frm.get_ref_size.options[frm.get_ref_size.selectedIndex].value;
 if (ref_size > 0){
    return true;
 }
 else{
    alert('You must select a size to add this product to your cart');
    return false;
 }

}
function inputCustomInfo2(frm) {
   var prefix0 = 'get_';
   var input_array = new Array('address','city','zip_code','ph01','ph02','ph03');
   var error_array = new Array('an Address','a city','a valid zip code','a valid phone number',
      'a valid phone number','a valid phone number'
   );

   if (frm.elements['get_first_name'].value.length == 0) {
      alert('Please enter your first name');
      frm.elements['get_first_name'].focus();
      return false;
   }

   if (frm.elements['get_last_name'].value.length == 0) {
      alert('Please enter your last name');
      frm.elements['get_last_name'].focus();
      return false;
   }

   if (!(validEmail(frm.elements['get_email'].value))) { 
      alert('Please enter a valid email address in the form of email@host.tag.');
      frm.elements['get_email'].focus();
      return false;
   }

   for (var i=0; i<input_array.length; i++) {
      var source = prefix0+input_array[i];          
      if (frm.elements[source].value.length == 0) {
         alert('Please enter '+error_array[i]);
         frm.elements[source].focus();
         return false;
      }
   }

   if (frm.elements['get_zip_code'].value) {
      myreg = new RegExp("^\\d+$");
      res = myreg.test(frm.elements['get_zip_code'].value);
      if (frm.elements['get_zip_code'].value == '0') res = 0;
      if (!res) {
         alert('Please enter a valid zip code');
         frm.elements['get_zip_code'].focus(); 
         return false;
      }
   }

   if (frm.elements['get_ph01'].value) {
      myreg = new RegExp("^\\d+$");
      res = myreg.test(frm.elements['get_ph01'].value);
      if (frm.elements['get_ph01'].value == '0') res = 0;
      if (!res) {
         alert('Please enter a valid phone number');
         frm.elements['get_ph01'].focus(); 
         return false;
      }
   }

   if (frm.elements['get_ph02'].value)  {
      myreg = new RegExp("^\\d+$");
      res = myreg.test(frm.elements['get_ph02'].value);
      if (frm.elements['get_ph02'].value == '0') res = 0;
      if (!res) {
         alert('Please enter a valid phone number');
         frm.elements['get_ph02'].focus(); 
         return false;
      }
   }
 
   if (frm.elements['get_ph03'].value)  {
      myreg = new RegExp("^\\d+$");
      res = myreg.test(frm.elements['get_ph03'].value);
      if (frm.elements['get_ph03'].value == '0') res = 0;
      if (!res) {
         alert('Please enter a valid phone number');
         frm.elements['get_ph03'].focus(); 
         return false;
      }
   }
  
   return true;
}


function validEmail(email, email2) {
  invalidChars = " /:,;";
  if (email == "") {
    return false;
  }
  if (email != email2) {
    return false;
  }
  for (i=0; i<invalidChars.length;i++) {
    badChar = invalidChars.charAt(i);
    if (email.indexOf(badChar,0) > -1) {
      return false;
    }
  }
  atPos = email.indexOf("@",1);
  if (atPos == -1) {
    return false;
  }
  if (email.indexOf("@",atPos+1) > -1) {
    return false;
  }
  periodPos = email.indexOf(".",atPos);
  if (periodPos == -1) {
    return false;
  }
  if (periodPos+3 > email.length) {
    return false;
  }
  return true;
}

function validEmail2(email) {
   return validEmail(email, email);
}

function viewform(m, w, h, scrol) {
   var scrolling = 'yes';
   var settings;
   var LeftPosition;
   var TopPosition;
   var win;

   if (!scrol) scrol = 'yes';

   LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
   TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
  
   settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scrol;

   if (scrol == 'no') settings = settings + ',resizable=no,maximize=no';
   if (scrol == 'yes') settings = settings + ',resizable=yes,maximize=yes';

   settings = settings + ',status=no,toolbar=no,directories=no,menubar=no,location=no';
          
   win = window.open(m, 'pre', settings);
   win.name = 'name';
   win.focus();
}

function changePswd(frm) {
   if (frm.elements['get_password_1'].value.length == 0) {
      alert('Please enter a password 6-10 characters long using only letters or numbers.');
      frm.elements['get_password_1'].focus();
      return false;
   }

   if (frm.elements['get_password_2'].value.length == 0) {
      alert('Please enter a Re-Password.');
      frm.elements['get_password_2'].focus();
      return false;
   }

   if (frm.elements['get_password_1'].value != frm.elements['get_password_2'].value) {
      alert('Your password confirmation does not match the original password');
      frm.elements['get_password_2'].focus();
      return false;
   }

   return true;
}

function check_basket_quantity(frm) {

   var i;
   var sum;
   
   for (i=0; i < frm.elements.length; i++) {
      if (frm.elements[i].type == "text") {
         if ((frm.elements[i].value.length == 0) || (frm.elements[i].value == 0)) {
            alert('Quantity should be greater than 0');
            frm.elements[i].focus(); 
            return false;  
         } 
         myreg = new RegExp("^\\d+$");
         res = myreg.test(frm.elements[i].value);
         if (!res) {
            alert('Quantity should be digit');
            frm.elements[i].focus(); 
            return false;
         }
       
      }
   }
   return true;
}
function validateQty(frm) {
   var i;
   var sum;
   sum=0;
   for (i=0; i < frm.elements.length; i++) {
      if (frm.elements[i].type == "text") {
         if (frm.elements[i].value > 0) {
            sum=sum+1;
         }          
         myreg = new RegExp("^\\d+$");
         res = myreg.test(frm.elements[i].value);
         if (!res) {
            alert('Quantity should be digit');
            frm.elements[i].focus(); 
            return false;
         }       
      }
   }
   if (sum > 0)
      return true;
   else{
      alert('Quantity should be greater than 0');
      return false;
   }   
}
function useCustomInfo2(chck, frm, prefix, prefix2) {
   var prefix0 = 'get_';
   var input_array = new Array('firstname','lastname','email','address','city','zip_code','phone');
   var select_array = new Array('ref_country', 'ref_state');

   if (chck.checked) {
      for (var i=0; i<input_array.length; i++) {
         var source = prefix0+prefix+input_array[i];
         var destin = prefix0+prefix2+input_array[i];
      
         frm.elements[destin].value = frm.elements[source].value;
      }

      for (var i=0; i<select_array.length; i++) {
         var source = prefix0+prefix+select_array[i];
         var destin = prefix0+prefix2+select_array[i];
         
         frm.elements[destin].options.length = 0;

         for (var j=0; j < frm.elements[source].options.length; j++) {
            frm.elements[destin].options.length = j+1;
            frm.elements[destin].options[j].value = frm.elements[source].options[j].value;
            frm.elements[destin].options[j].text  = frm.elements[source].options[j].text;
         }
         
         frm.elements[destin].selectedIndex = frm.elements[source].selectedIndex;
      }
   }
   return true;
}

function useBillingInfo(chck, frm, prefix, prefix2) {
   var prefix0 = 'get_';
   var input_array = new Array('firstname','lastname','email','address','city','zip_code','ph01','ph02','ph03','ph04');
   var select_array = new Array('ref_country', 'ref_state');

   if (chck.checked) {
      for (var i=0; i<input_array.length; i++) {
         var source = prefix0+prefix+input_array[i];
         var destin = prefix0+prefix2+input_array[i];
         frm.elements[destin].value = frm.elements[source].value;
      }

      for (var i=0; i<select_array.length; i++) {
         var source = prefix0+prefix+select_array[i];
         var destin = prefix0+prefix2+select_array[i];
         
         frm.elements[destin].options.length = 0;

         for (var j=0; j < frm.elements[source].options.length; j++) {
            frm.elements[destin].options.length = j+1;
            frm.elements[destin].options[j].value = frm.elements[source].options[j].value;
            frm.elements[destin].options[j].text  = frm.elements[source].options[j].text;
         }
         
         frm.elements[destin].selectedIndex = frm.elements[source].selectedIndex;
      }
   }
   return true;
}

function OrderCheckout(frm) {

 var flag=0;
 for (var i=0; i<frm.elements.length; i++){
    if(frm.elements[i].type == "radio"){   
       if(frm.elements[i].checked == true){
         flag = 1;
       }
    }
 }    
 if (flag == 0){
    alert('Please select Shipping Type.');
    return false;
 }   
 for (var i=0; i<frm.elements.length; i++)
   if(frm.elements[i].name  ==  'ref_order'){
      if(frm.elements[i].value > 0 )
         frm.submit();
         return false;
   }    
   alert('Please calculate order');
   return false;
}


function inputOrderInfo(frm) {
   var prefix0 = 'get_';
   var input_array = new Array('billing_firstname','billing_lastname','billing_address','billing_city','billing_zip_code',
      'shipping_firstname','shipping_lastname','shipping_email','shipping_address','shipping_city','shipping_zip_code'
   );

   var error_array = new Array('Billing Firstname','Billing Lastname','Billing Address','Billing City','Billing Zip Code',
      'Shipping Firstname','Shipping Lastname','Shipping Email','Shipping Address','Shipping City','Shipping Zip Code'
   );

      for (var i=0; i<input_array.length; i++) {
         var source = prefix0+input_array[i];          
         if (frm.elements[source].value.length == 0) {
            alert(error_array[i].substr(0,1).toUpperCase()+error_array[i].substr(1)+' can not be empty ');
            frm.elements[source].focus();
            return false;
         }
      }

      if (frm.elements['get_billing_zip_code'].value) {
         myreg = new RegExp("^\\d+$");
         res = myreg.test(frm.elements['get_billing_zip_code'].value);
         if (frm.elements['get_billing_zip_code'].value == '0') res = 0;
         if (!res) {
            alert('Please enter a valid billing zip code');
            frm.elements['get_billing_zip_code'].focus(); 
            return false;
         }
      }

      if (frm.elements['get_shipping_zip_code'].value) {
         myreg = new RegExp("^\\d+$");
         res = myreg.test(frm.elements['get_shipping_zip_code'].value);
         if (frm.elements['get_shipping_zip_code'].value == '0') res = 0;
         if (!res) {
            alert('Please enter a valid shipping zip code');
            frm.elements['get_shipping_zip_code'].focus(); 
            return false;
         }
      }

   return true;
}

function inputOrderBillingInfo(frm) {
   var prefix0 = 'get_';
   var input_array = new Array('billing_firstname','billing_lastname','billing_email','billing_address','billing_city','billing_zip_code');

   var error_array = new Array('Billing Firstname','Billing Lastname','Billing Email','Billing Address','Billing City','Billing Zip Code');

      for (var i=0; i<input_array.length; i++) {
         var source = prefix0+input_array[i];          
         if (frm.elements[source].value.length == 0) {
            alert(error_array[i].substr(0,1).toUpperCase()+error_array[i].substr(1)+' can not be empty ');
            frm.elements[source].focus();
            return false;
         }
      }

      if (frm.elements['get_billing_zip_code'].value) {
         myreg = new RegExp("^\\d+$");
         res = myreg.test(frm.elements['get_billing_zip_code'].value);
         if (frm.elements['get_billing_zip_code'].value == '0') res = 0;
         if (!res) {
            alert('Please enter a valid billing zip code');
            frm.elements['get_billing_zip_code'].focus(); 
            return false;
         }
      }

   return true;
}

function inputOrderShippingInfo(frm) {
   var prefix0 = 'get_';
   var input_array = new Array('shipping_firstname','shipping_lastname','shipping_email','shipping_address','shipping_city','shipping_zip_code');

   var error_array = new Array('Shipping Firstname','Shipping Lastname','Shipping Email','Shipping Address','Shipping City','Shipping Zip Code');

      for (var i=0; i<input_array.length; i++) {
         var source = prefix0+input_array[i];          
         if (frm.elements[source].value.length == 0) {
            alert(error_array[i].substr(0,1).toUpperCase()+error_array[i].substr(1)+' can not be empty ');
            frm.elements[source].focus();
            return false;
         }
      }

      if (frm.elements['get_shipping_zip_code'].value) {
         myreg = new RegExp("^\\d+$");
         res = myreg.test(frm.elements['get_shipping_zip_code'].value);
         if (frm.elements['get_shipping_zip_code'].value == '0') res = 0;
         if (!res) {
            alert('Please enter a valid shipping zip code');
            frm.elements['get_shipping_zip_code'].focus(); 
            return false;
         }
      }

   return true;
}

function inputOrderShippingZIP(frm) {
    if (frm.elements['get_shipping_zip_code'].value.length == 0) {
       alert('Please enter a valid shipping zip code');
       frm.elements['get_shipping_zip_code'].focus();
       return false;
    }

   if (frm.elements['get_shipping_zip_code'].value) {
      myreg = new RegExp("^\\d+$");
      res = myreg.test(frm.elements['get_shipping_zip_code'].value);
      if (frm.elements['get_shipping_zip_code'].value == '0') res = 0;
      if (!res) {
         alert('Please enter a valid shipping zip code');
         frm.elements['get_shipping_zip_code'].focus(); 
         return false;
      }
   }
   
   frm.submit(); return false;
//   return true;
}

function HideALL() {
   if (document.all) {
      document.all['UPS'].style.display = "none"
      document.all['FIXED'].style.display = "none"
   }else if (document.getElementById) { 
      document.getElementById('UPS').style.display = "none"
      document.getElementById('FIXED').style.display = "none"
   }  
}

function ShowDIV(sDIV) {  
   //hide all elements before revealing selected
   HideALL();

   if (document.all) {
      document.all[sDIV].style.display = "block"
   }else if (document.getElementById) {
      document.getElementById(sDIV).style.display = "block"
   }
}

function onOrderAdd(frm) {
   if (!inputOrderShippingInfo(frm)) return false;

   if (!frm.shipping_flag.value) {
      alert('Shipping must be calculated before order processing.');
      return false;
   }
   if (!frm.discount_flag.value) {
      alert('Discount coupon was not found in our database or expired. Please specify valid code or continue without it.');
      return false;
   }

   return true;
}
function resize() {
var i=0;
var LeftPosition;
var TopPosition;
var w;
var h;
  if (navigator.appName == 'Netscape') i=40;
  if (document.images[0].name != 'close') 
  { 
    w = document.images[0].width+100;
    h = document.images[0].height+130-i;
    window.resizeTo(w, h);
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
    window.moveTo(LeftPosition, TopPosition); 
  }else{
    w = 420;
    h = 370;   
    window.resizeTo(w, h);
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
    window.moveTo(LeftPosition, TopPosition); 

  }
  self.focus();
}
flag=false;

function ValidFocus(frm) {
   if (!validPhone(frm.get_phone1.value, 3)) {
      alert('Please enter a valid phone number in the form of (3-3-4).');
      frm.get_phone1.focus();
      return false;
   }
   if (!validPhone(frm.get_phone2.value, 3)) {
      alert('Please enter a valid phone number in the form of (3-3-4).');
      frm.get_phone2.focus();
      return false;
   }
   if (!validPhone(frm.get_phone3.value, 4)) {
      alert('Please enter a valid phone number in the form of (3-3-4).');
      frm.get_phone3.focus();
      return false;
   }
   if (!validPhone(frm.get_aphone1.value, 3)) {
      alert('Please enter a valid phone number in the form of (3-3-4).');
      frm.get_aphone1.focus();
      return false;
   }
   if (!validPhone(frm.get_aphone2.value, 3)) {
      alert('Please enter a valid phone number in the form of (3-3-4).');
      frm.get_aphone2.focus();
      return false;
   }
   if (!validPhone(frm.get_aphone3.value, 4)) {
      alert('Please enter a valid phone number in the form of (3-3-4).');
      frm.get_aphone3.focus();
      return false;
   }
   if (!(validEmail(frm.get_email.value, frm.get_email2.value))) { 
      alert('Please enter a valid email address in the form of email@host.tag.');
      frm.get_email.focus();
      return false;
   }
   return true;
}

function ValidFocusFeedback(frm) {
   if (!validPhone(frm.get_phone1.value, 3)) {
      alert('Please enter a valid phone number in the form of (3-3-4).');
      frm.get_phone1.focus();
      return false;
   }
   if (!validPhone(frm.get_phone2.value, 3)) {
      alert('Please enter a valid phone number in the form of (3-3-4).');
      frm.get_phone2.focus();
      return false;
   }
   if (!validPhone(frm.get_phone3.value, 4)) {
      alert('Please enter a valid phone number in the form of (3-3-4).');
      frm.get_phone3.focus();
      return false;
   }
   if (!(validEmail(frm.get_email.value, frm.get_email2.value))) { 
      alert('Please enter a valid email address in the form of email@host.tag.');
      frm.get_email.focus();
      return false;
   }
   return true;
}

function ValidFocusEmailFriend(frm) {
   if (!(validEmail2(frm.get_recipient_email.value))) { 
      alert('Please enter a valid email address in the form of email@host.tag.');
      frm.get_recipient_email.focus();
      return false;
   }
   if (!(validEmail2(frm.get_your_email.value))) { 
      alert('Please enter a valid email address in the form of email@host.tag.');
      frm.get_your_email.focus();
      return false;
   }
   return true;
}

function validPhone(phone1, num) {
  if (!(phone1)) {
    return true;
  }
  if ((phone1.length != num)) {
    return false;
  }
  return !isNaN(phone1);
}

function conf() {
  var reply = confirm('This record will be permanently deleted. Do you want to continue?');

  if(reply) {
     return true;
   } else {
     return false;
   }
}

function conf_send() {
  var reply = confirm('Are you sure you want to send this email to all specified users?');

  if(reply) {
     return true;
   } else {
     return false;
   }
}

// JS Calendar
var calendar = null; // remember the calendar object so that we reuse
// it and avoid creating another
		

// This function gets called when an end-user clicks on some date
function selected(cal, date) {
	cal.sel.value = date; // just update the value of the input field
}

// And this gets called when the end-user clicks on the _selected_ date,
// or clicks the "Close" (X) button.  It just hides the calendar without
// destroying it.
function closeHandler(cal) {
	cal.hide();			// hide the calendar

	// don't check mousedown on document anymore (used to be able to hide the
	// calendar when someone clicks outside it, see the showCalendar function).
	Calendar.removeEvent(document, "mousedown", checkCalendar);
}



function checkCalendar(ev) {
	var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
	for (; el != null; el = el.parentNode)
	// FIXME: allow end-user to click some link without closing the
	// calendar.  Good to see real-time stylesheet change :)
	if (el == calendar.element || el.tagName == "A") break;
	if (el == null) {
		// calls closeHandler which should hide the calendar.
		calendar.callCloseHandler(); Calendar.stopEvent(ev);
	}
}

// This function shows the calendar under the element having the given id.
// It takes care of catching "mousedown" signals on document and hiding the
// calendar if the click was outside.
function showCalendar(id) {
	var el = document.getElementById(id);
	if (calendar != null) {
		// we already have one created, so just update it.
		calendar.hide();		// hide the existing calendar
		calendar.parseDate(el.value); // set it to a new date
	} else {
		// first-time call, create the calendar
		var cal = new Calendar(true, null, selected, closeHandler);
		calendar = cal;		// remember the calendar in the global
		cal.setRange(1900, 2070);	// min/max year allowed
		calendar.create();		// create a popup calendar
	}
	calendar.sel = el;		// inform it about the input field in use
	calendar.showAtElement(el);	// show the calendar next to the input field

	// catch mousedown on the document
	Calendar.addEvent(document, "mousedown", checkCalendar);
	return false;
}




opera = (navigator.userAgent.indexOf('Opera') >= 0)? true : false;
ie = (document.all && !opera)? true : false;
dom = (document.getElementById && !ie && !opera)? true : false;

var expiration = new Date();
expiration.setTime(expiration.getTime() + 3600*3600*3600);


function showtranscript(elemId,displayValue) {
  if (dom) {

      if (displayValue) {
         document.getElementById(elemId).style.display = displayValue;
         return 0;
      }

      if (document.getElementById(elemId).style.display == "none") {
         document.getElementById(elemId).style.display = "block";
      } else if (document.getElementById(elemId).style.display == "block") {
         document.getElementById(elemId).style.display = "none";
      } 
      
  } else if (ie) {

    if (displayValue) {
       document.all[elemId].style.display =  displayValue;
       return 0;
    }

    if (document.all[elemId].style.display == "block") {
       document.all[elemId].style.display = "none";
    } else if (document.all[elemId].style.display == "none") {
      document.all[elemId].style.display = "block";
    }

  }
}

function display(cookie_name, id) {
    var template_category_cookie;

    template_category_cookie = GetCookie(cookie_name);

//alert(template_category_cookie);
    if (template_category_cookie == 1) {
       SetCookie(cookie_name, "1", expiration, "", "","") 
       showtranscript(id, 'block');
    } 

    if (template_category_cookie == 0) {
       SetCookie(cookie_name, "0", expiration, "", "","") 
       showtranscript(id, 'none');
    }

    if ((template_category_cookie == null)) {
       showtranscript(id, 'none');     
    }

    return true;                            
}

function onCookieChange(cookie_name, id) {
 
  if (dom) {
      if (document.getElementById(id).style.display == "none") {
         SetCookie(cookie_name, "0", expiration, "", "","") 
      } else if (document.getElementById(id).style.display == "block") {
         SetCookie(cookie_name, "1", expiration, "", "","") 
      } 
      
  } else if (ie) {

    if (document.all[id].style.display == "block") {
       SetCookie(cookie_name, "1", expiration, "", "","") 
    } else if (document.all[id].style.display == "none") {
       SetCookie(cookie_name, "0", expiration, "", "","") 
    }

  }
}


function SetCookie(name, value, expires, path, domain, secure) { 

   var mycookie = name + "=" + escape(value);
   var myexpires = new Date();
//   myexpires.setTime(myexpires.getTime() + 5000);
   myexpires.setTime(0);
   mycookie = mycookie + "; myexpires=" + myexpires.toGMTString();
   document.cookie = mycookie;
}


function GetCookie(name) { 
   var arg = name + "="; 
   var alen = arg.length; 
   var clen = document.cookie.length; 
   var i = 0; 

   while (i < clen) { 
     var j = i + alen; 
     if (document.cookie.substring(i, j) == arg)  return getCookieVal (j); 
     i = document.cookie.indexOf(" ", i) + 1; 
     if (i == 0) break; 
   }
    
   return null; 
} 


function getCookieVal (offset) { 
  var endstr = document.cookie.indexOf (";", offset); 
  if (endstr == -1) endstr = document.cookie.length; 
   return unescape(document.cookie.substring(offset, endstr)); 
} 
function onModificationChange(n) {
   var modifications=new Array();
   for (var i=0; i<n; i++) {
      modifications.length++;
      modifications[modifications.length-1] = window.document.getElementById('modification_'+(i+1)).options[window.document.getElementById('modification_'+(i+1)).selectedIndex].value;
   }
   i++
   while(window.document.getElementById('modification_'+i)) {
//      var obj = window.document.getElementById('modification_'+i);
      window.document.getElementById('mod_div_'+i).hide = '';
//      delete obj;
      i++;
   }
   req = new JsHttpRequest();
   req.onreadystatechange = changeOption;
   req.open(null, 'ajax.php', true);
   req.send({act:'option', modification_options:modifications, ref_item: window.document.getElementById('item_id').value, n:n});
}

function changeOption() {
   if (req.readyState != 4) return null;
//   if (req.responseJS.str) window.document.getElementById('modifications').innerHTML += req.responseJS.str;
   window.document.getElementById('price').innerHTML = 'Price: $'+req.responseJS.rec.price;
   window.document.getElementById('cattitle').innerHTML = req.responseJS.rec.title;
   window.document.getElementById('ref_item_modification').value = req.responseJS.rec.id;
   for (var i in req.responseJS.options_str) {
      window.document.getElementById('mod_div_'+i).innerHTML=req.responseJS.options_str[i];
      window.document.getElementById('mod_div_'+i).show;
   }
   return false;
//   window.document.getElementById(city).options.length=0;
//   for (option in options) {
//      window.document.getElementById(city).options.length++;
//      window.document.getElementById(city).options[window.document.getElementById(city).options.length-1].text=options[option].City;
//      window.document.getElementById(city).options[window.document.getElementById(city).options.length-1].value=options[option].City;
//   }
}

/*
Array.prototype.toString = 
Object.prototype.toString = function() {
  var cont = [];
  var addslashes = function(s) {
    // Ð˜ÑÐ¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ñ‚ÑŒ replace ÐÐ•Ð›Ð¬Ð—Ð¯ - Ð² ÐžÐ¿ÐµÑ€Ðµ
    // Ð¿Ñ€Ð¾Ð¸ÑÑ…Ð¾Ð´Ð¸Ñ‚ Ð·Ð°Ñ†Ð¸ÐºÐ»Ð¸Ð²Ð°Ð½Ð¸Ðµ, Ñ‚.Ðº. Ð¸Ð· replace
    // Ð·Ð°Ñ‡ÐµÐ¼-Ñ‚Ð¾ Ð²Ñ‹Ð·Ñ‹Ð²Ð°ÐµÑ‚ÑÑ Object.toString().
    return 
      s.split('\\').join('\\\\').split('"').join('\\"');
  }
  for (var k in this) {
    if (cont.length) cont[cont.length-1] += ",";
    var v = this[k];
    var vs = '';
    if (v.constructor == String) 
      vs = '"' + addslashes(v) + '"';
    else 
      vs = v.toString();
        if (this.constructor == Array)
      cont[cont.length]
        else 
      cont[cont.length] = k + ": " + vs;
  }
  // Ð—Ð´ÐµÑÑŒ Ñ‚Ð¾Ð¶Ðµ Ð½ÐµÐ»ÑŒÐ·Ñ Ð´ÐµÐ»Ð°Ñ‚ÑŒ replace()! 
  cont = "  " + cont.join("\n").split("\n").join("\n  ");
  var s = cont;
  if (this.constructor == Object) {
    s = "{\n"+cont+"\n}";
  } else if (this.constructor == Array) {
    s = "[\n"+cont+"\n]";
  }
  return s;
}
*/

function expand_admin() {
   var i=0;
   window.document.getElementById('expand_link_'+arguments[0]).innerHTML;
   while(arguments[++i] > 0) {
//      alert(window.document.getElementById('tr_'+arguments[i]).style.display);
      if (window.document.getElementById('tr_'+arguments[i]).style.display=="none") {
	 window.document.getElementById('tr_'+arguments[i]).style.display="table-row";
	 if (false && window.document.getElementById('expand_link_'+arguments[i]) && window.document.getElementById('expand_link_'+arguments[i]).innerHTML=='[-]') {
//	    alert(window.document.getElementById('expand_link_'+arguments[i]));
	    window.document.getElementById('expand_link_'+arguments[i]).onClick();
	 }
	 window.document.getElementById('expand_link_'+arguments[0]).innerHTML = '[-]';
      }
      else {
	 window.document.getElementById('tr_'+arguments[i]).style.display="none";
	 if (window.document.getElementById('expand_link_'+arguments[i]) && window.document.getElementById('expand_link_'+arguments[i]).innerHTML=='[-]') {
///	    alert(window.document.getElementById('expand_link_'+arguments[i]));
	    window.document.getElementById('expand_link_'+arguments[i]).onclick();
	 }
	 window.document.getElementById('expand_link_'+arguments[0]).innerHTML = '[+]';
      }
   }
}

function sugnup_submit(input_name, input_email, hotel_id, area) {
   error_div = window.document.getElementById('signupError');
   error_div.style.display='none';
   if (!validEmail2(input_email)) {
      error_div.innerHTML = 'Email is invalid';
      error_div.style.display = 'block';
   }
   if (!input_email) {
      error_div.innerHTML = 'Email can\'t be empty';
      error_div.style.display = 'block';
   }
   if (error_div.style.display == 'none') {
      window.document.getElementById('joinEmailButton').src='signup.php?ref_parent='+hotel_id+'&name='+escape(input_name)+'&email='+escape(input_email)+'&area='+area;
      hidePopup();
   }
   return false;
}

function onReservationUpdate(value, input_month, input_day) {
   var months = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
   var arr = value.split('/');
   var month_str = months[arr[1]-1];//+' '+arr[2]

   var found = false;
   for (var i in input_month.options) {
      if (input_month.options[i] && month_str == input_month.options[i].value) {
	  input_month.options[i].selected=true;
	 found = true;
      }
   }
   if (!found) {
      var new_opt = new Option(month_str, month_str, false, false);
      input_month.options[input_month.options.length] = new_opt;
      input_month.selectedIndex=input_month.options.length-1;
   }
   input_day.selectedIndex=arr[0];//-1;
   if (input_month.id == 'roomlistInMonthYear')
      on_arrival_day_change();
}

/*
function on_arrival_day_change() {
   var cnt = new Array(12);
   cnt['Jan'] = 31;
   cnt['Feb'] = 29;
   cnt['Mar'] = 31;
   cnt['Apr'] = 30;
   cnt['May'] = 31;
   cnt['Jun'] = 30;
   cnt['Jul'] = 31;
   cnt['Aug'] = 31;
   cnt['Sep'] = 30;
   cnt['Oct'] = 31;
   cnt['Nov'] = 30;
   cnt['Dec'] = 31;

   input_arr_day = window.document.getElementById('roomlistInDay');
   input_arr_mon = window.document.getElementById('roomlistInMonthYear');
   input_dep_day = window.document.getElementById('roomlistOutDay');
   input_dep_mon = window.document.getElementById('roomlistOutMonthYear');
   if (input_arr_day.selectedIndex<cnt[input_arr_mon[input_arr_mon.selectedIndex].value]) {
      input_dep_day.selectedIndex = input_arr_day.selectedIndex+1;
      input_dep_mon.selectedIndex = input_arr_mon.selectedIndex;
   } else {
      input_dep_day.selectedIndex = 0;
      input_dep_mon.selectedIndex = input_arr_mon.selectedIndex+1;
   }
   $('#roomlistOutMonthYear, #roomlistOutDay').resetSS();
   return false;
}
*/
function on_arrival_day_change() {
   var cnt = new Array(12);
/*
   cnt['Jan'] = 31;
   cnt['Feb'] = 29;
   cnt['Mar'] = 31;
   cnt['Apr'] = 30;
   cnt['May'] = 31;
   cnt['Jun'] = 30;
   cnt['Jul'] = 31;
   cnt['Aug'] = 31;
   cnt['Sep'] = 30;
   cnt['Oct'] = 31;
   cnt['Nov'] = 30;
   cnt['Dec'] = 31;
*/
   cnt['1'] = 31;
   cnt['2'] = 29;
   cnt['3'] = 31;
   cnt['4'] = 30;
   cnt['5'] = 31;
   cnt['6'] = 30;
   cnt['7'] = 31;
   cnt['8'] = 31;
   cnt['9'] = 30;
   cnt['10'] = 31;
   cnt['11'] = 30;
   cnt['12'] = 31;


   input_arr_day = window.document.getElementById('roomlistInDay');
   input_arr_mon = window.document.getElementById('roomlistInMonthYear');
   input_dep_day = window.document.getElementById('roomlistOutDay');
   input_dep_mon = window.document.getElementById('roomlistOutMonthYear');
   if (input_arr_day.selectedIndex<cnt[input_arr_mon[input_arr_mon.selectedIndex].value]) {
      input_dep_day.selectedIndex = input_arr_day.selectedIndex+1;
      input_dep_mon.selectedIndex = input_arr_mon.selectedIndex;
   } else {
      input_dep_day.selectedIndex = 0;
      input_dep_mon.selectedIndex = input_arr_mon.selectedIndex+1;
   }
   $('#roomlistOutMonthYear, #roomlistOutDay').resetSS();
   return false;
}


function get_date_status(date, year, month, day) {
   var offset = (Date.parse(date) - Date.parse(Date()))/(7*24*60*60*1000);
   return (offset<0 || offset>=51);
}

function on_arr_change() {
   input_arr_day = window.document.getElementById('roomlistInDay');
   input_arr_mon = window.document.getElementById('roomlistInMonthYear');
   onReservationUpdate(input_arr_mon.options[input_arr_mon.selectedIndex].value+'/'+input_arr_day.options[input_arr_day.selectedIndex], input_arr_mon, input_arr_day);
}

function on_arr_month_change() {
}


