var menuids=["treemenu1"] ;
function buildsubmenus_horizontal(){
	
for (var i=0; i<menuids.length; i++){
  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul");
  var new_var;
  new_var = ultags.length;
    for (var t=0; t<ultags.length; t++){
		new_var = new_var -1;
		if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu
			ultags[t].style.top=ultags[t].parentNode.offsetHeight+"px" ;//dynamically position first level submenus to be height of main menu item
			if(new_var==4)
				ultags[t].parentNode.getElementsByTagName("a")[0].className="bgNone";
			else
				ultags[t].parentNode.getElementsByTagName("a")[0].className="mainfoldericon";
			
		}
		else{ //else if this is a sub level menu (ul)
		  ultags[t].style.left=ultags[0].getElementsByTagName("a")[0].offsetWidth+"px" ;//position menu to the right of menu item that activated it
    	ultags[t].parentNode.getElementsByTagName("a")[0].className="subfoldericon";
		}
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.visibility="visible";
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.visibility="hidden";
    }
    }
  }
}

if (window.addEventListener)
window.addEventListener("load", buildsubmenus_horizontal, false);
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus_horizontal);

function validation(){
 var demo     = document.frm.email.value;
 if(demo == '')
 {
 	alert("Email field is blank");
 	return false;
 }
 if (echeck(demo)==false){
		
		return false
	}
 return true;
}
function echeck(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 ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true;
		 
	}
	/* have to add in misc.js*/
function check_form() {
  var error = 0;
  var error_message = "<?php echo JS_ERROR; ?>";

  var registry_occasion_id = document.add_registry.registry_occasion_id.value;
  var registry_occasion_date = document.add_registry.registry_occasion_date.value;

  if (registry_occasion_id == "") {
    error_message = error_message + "<?php echo JS_REGISTRY_OCCASION_ID; ?>";
    error = 1;
  }

  if (registry_occasion_date == "" || registry_occasion_date.length < 10) {
    error_message = error_message + "<?php echo JS_REGISTRY_OCCASION_DATE; ?>";
    error = 1;
  }

  if (error == 1) {
    alert(error_message);
    return false;
  } else {
    return true;
  }
}

function check_form_search() {
  var error_message = "<?php echo JS_ERROR; ?>";
  var error_found = false;
  var error_field;
  var registry_keywords_first = document.registry_search.registry_keywords_first.value;
  var registry_keywords_last = document.registry_search.registry_keywords_last.value;
  var registry_occasion = document.registry_search.registry_occasion.value;

  if (registry_occasion == '') {
    error_message = error_message + "<?php echo JS_SELECT_OCCASION; ?>";
    error_field = document.registry_search.registry_occasion;
    error_found = true;
  }
  if ( ((registry_keywords_last == '') || (registry_keywords_last.length < 2)) ) {
    error_message = error_message + "<?php echo JS_LAST_NAME_MINIMUM_TWO; ?>";
    error_field = document.registry_search.registry_keywords_last;
    error_found = true;
  }
  if ( ((registry_keywords_first == '') || (registry_keywords_first.length < 1)) ) {
    error_message = error_message + "<?php echo JS_FIRST_NAME_MINIMUM_ONE; ?>";
    error_field = document.registry_search.registry_keywords_first;
    error_found = true;
  }

  if (error_found == true) {
    alert(error_message);
    error_field.focus();
    return false;
  } else {
    return true;
  }
}

function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=280,screenX=150,screenY=150,top=150,left=150')
}
  // JavaScript Document
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}

//window.attachEvent("onload", correctPNG);

if (window.addEventListener)
window.addEventListener("load", correctPNG, false);
else if (window.attachEvent)
window.attachEvent("onload", correctPNG);



function confirmationdelete(loc)
	{
	if(confirm("Are you sure you want to delete this product from cart?"))
	{ 

	window.open(loc,'_self');
	//window.location.href=loc;
	return false; 
	}
 }
