sfHover = function () {
	var el = document.getElementById("nav").childNodes;
	for (var i = 0; i < el.length; i++) {
		if (el[i].getElementsByTagName("LI").length > 0 && el[i].id != navon + "_li") {			
			el[i].onmouseover = function() {
				if (navon.length > 0 && navon != "home" && navon != "book") document.getElementById(navon).className = "nav-off";
				this.className = "sfhover";
			}
			el[i].onmouseout = function() {				
				if (navon.length > 0 && navon != "home" && navon != "book") document.getElementById(navon).className = "nav-on";
				this.className = "";
			}
		}
	}
}

if (window.attachEvent)
	window.attachEvent("onload", sfHover);
else
	window.addEventListener("load", sfHover, false);
	
var win=null;
function openWindow(mypage,myname,w,h,scroll,pos){
	if(pos=="center"){
		LeftPosition=(screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height)?(screen.height-h)/2:100;
	}else if((pos!="center" && pos!="random") || pos==null){
		LeftPosition=0;TopPosition=20
 	}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(mypage,myname,settings);
	if(win.focus){
		win.focus();
	}
}

// Use processPromoCode() now
function processBook(){
	var item = document.getElementById('bnform');
	if(item){
		document.location.href = item.value;
	}
}

function processPromoCode(){
	var button = document.getElementById('bnform');
	//var promo = document.getElementById('txtPromoCode');
	
	var promo = "";
	
	// if(button){
		// var button_value = button.value;
		// if(promo.value) {
			// Check if the promocode is valid
			$.ajax({
                url: "../promocode.asp?promoCode=" + promo,
                dataType: "text",
                success: function(data) {
                    if (data != null) {
                        // We have a valid ENTA URL, redirect the user
                        //window.location = data.result;
						alert(data);
                    }
                    else {
                        // Bad promo code
                        alert("This is not a valid promotion code for this event.  Please re-enter or select a performance below.");

                        // $("#promoCode").val("");
                    }
                }
            });
			
			// W--- is the placeholder for the Web Promo code. See subprocs.asp#writeBookOnline()
			//button_value = button_value.replace('|W---', '|W' + promo.value);
			
		// } else {
			// button_value = button_value.replace('|W---', ''); // Remove the promo code placeholder if we don't have a code to use
		// }
		
		// //document.location.href = button_value;
	// }
}
