function popUPcenter(url, target, w, h) {
    putItCenter = window.open(url, target, 'width=' + w + ',height=' + h + ',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,left=' + ((screen.availWidth - w - 10) * .5) + ',top=' + ((screen.availHeight - h - 30) * .5));
	putItCenter.focus();
}

function popUpCenterMenu(url, target, w, h, m) {
    putItCenter = window.open(url, target, 'width=' + w + ',height=' + h + ',menubar=' + m + ',location=0,directories=0,status=0,toolbar=0,scrollbars=1,resizable=0,left=' + ((screen.availWidth - w - 10) * .5) + ',top=' + ((screen.availHeight - h - 30) * .5));
	putItCenter.focus();
}

function popUpCenterResizable(url, target, w, h) {
    putItCenter = window.open(url, target, 'width=' + w + ',height=' + h + ',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,left=' + ((screen.availWidth - w - 10) * .5) + ',top=' + ((screen.availHeight - h - 30) * .5));
	putItCenter.focus();
}

function popWindow(fileName) {
	var newWin = window.open(fileName, "child", "width=626,height=318,scrollbars=no,resizable=1");	
}

function checkMaxLength(textarea, evt, maxLength) {
    if (textarea.selected && evt.shiftKey) {
        // ignore shift click for select
        return true;
        var allowKey = false;
        if (textarea.selected && textarea.selectedLength > 0) {
            allowKey = true;
        } else {
            var keyCode = document.layers ? evt.which : evt.keyCode;
            if (keyCode < 32 && keyCode != 13) {
                allowKey = true;
            } else {
                allowKey = textarea.value.length < maxLength;
            }
            textarea.selected = false;
            return allowKey;
        }
    }
}

function promowindow(url, attrib) {
    window.open(url, '', attrib);
}

function showForm(){
    document.getElementById('login_form').style.display='block';
    document.getElementById('login_buttons').style.display='none';
}

function showStudent(){
    if (document.getElementById('student').style.display == 'none')
    {
        document.getElementById('student').style.display='block';
    }
    else
    {
        document.getElementById('student').style.display='none';
    }
}

function NewWindowSend(url, myname, w, h, scroll) {
    putItCenter = window.open(url, myname, 'width=' + w + ',height=' + h + ',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,left=' + ((screen.availWidth - w - 10) * .5) + ',top=' + ((screen.availHeight - h - 30) * .5));
	putItCenter.focus();
}
//Original Function - test during Teamsite testing to make sure above version is adequate
//function NewWindowSend(mypage, myname, w, h, scroll) {
//	var winl = (screen.width - w) / 2;
//	var wint = (screen.height - h) / 2;
//	var eventinfo = <% if(request.getParameter("eventid") != null){ out.print(request.getParameter("eventid")); }else{out.print("null");}%>;
//	var selected_date = <% if(request.getParameter("selecteddate") != null){ out.print(request.getParameter("selecteddate")); }else{out.print("null");}%>;
//	mypage = mypage + '?eventid=' + eventinfo + '&selecteddate='+ selected_date;
//	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resize=0'
//	win = window.open(mypage, myname, winprops)
//	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
//}

//Gift Shop Functions
function addShopProductToCart(productId,defaultPerfCode) {
	//SET AND VALIDATE PERFCODE
	if (document.getElementById('attr_' + productId) != null) {
		var productAttribute = document.getElementById('attr_' + productId).value;
    } else {
    	var productAttribute = 0;
    }
    
    //SET AND VALIDATE QUANTITY
	if (document.getElementById('qty_' + productId).value > 0) {
		var productQuantity = document.getElementById('qty_' + productId).value;
		
		if (productQuantity > 10) {
			alert("We're sorry. The maximum number of items you can add to your cart at one time is 10.");
		} else {
			//SET PROMO CODE
			if (document.getElementById('promo_' + productId) != null) {
				var promoCode = document.getElementById('promo_' + productId).value.replace("(optional)","");

                window.location.href = "/article/the_basics/shop/index.html?productId=" + productId + "&productAttribute=" + productAttribute + "&productQuantity=" + productQuantity + "&promoCode=" + promoCode;
			} else {
				window.location.href = "/article/the_basics/shop/index.html?productId=" + productId + "&productAttribute=" + productAttribute + "&productQuantity=" + productQuantity;
			}
		}
	} else {
		alert("Please enter quantity");
	}
}

function buyButtonSmall(id,date,div) {
	var today = new Date();
	var eventDate = new Date();
	var parsedDate = Date.parse(date);
	
	eventDate.setTime(parsedDate);
	
	if (document.getElementById(div) != null) {
		var el = document.getElementById(div);
		if (today < eventDate) {
			el.innerHTML = "<a href=\"/SiteCode/Purchase/SeatSelectionPerformance.aspx?startWorkflow=true&quickBuy=false&quantity=1&eventId="+id+"\"><img src=\"/common/imgs/btn_buy_tickets_small.gif\" width=\"67\" height=\"21\" border=\"0\" /></a>";
		}
	}
}

function popUpShopLargeImg(shopId) {
	var html= "<html><body marginwidth=\"0\" marginheight=\"0\" leftmargin=\"0\" topmargin=\"0\"><img src=\"/common/imgs/shop/"+shopId+"l.jpg\"/ vspace=\"5\" hspace=\"5\" align=\"center\"><\/body><\/html>";
	
	LWin = window.open("","","width=430,height=510,left=125,top=125");
	LWin.document.write(html);
}
//Gift Shop Functions-End

//Search Functions -Start
function more_search_options() {
    var more_search_span = document.getElementById('more_search');
    var more_search_fields = document.getElementById('more_search_fields');
    
    document.getElementById('search_events').checked = true;
    
    more_search_span.innerHTML = "<a href='#' onClick='javascript:basic_search()'>Basic Search<\/a>";
    
    more_search_fields.style.visibility = "";
}

function basic_search() {
    var more_search_span = document.getElementById('more_search');
    var more_search_fields = document.getElementById('more_search_fields');
    
    document.getElementById('search_events').checked = true;
    
    more_search_span.innerHTML = "<a href='#' onClick='javascript:more_search_options()'>More Search Options<\/a>";
    
    more_search_fields.style.visibility = "hidden";
}

function selectAllLocations(selectElement) {
    var search_locations = document.getElementById('search_locations');
    var inputs = search_locations.getElementsByTagName('input');
    if (selectElement.checked == true) {
        for(var i = 0; i < inputs.length; i++) {
            inputs[i].checked = true;
        }
        document.getElementById('select_all_label').innerHTML = "Deselect All";
    }
    else {
        for(var i = 0; i < inputs.length; i++) {
            inputs[i].checked = false;
        }
        document.getElementById('select_all_label').innerHTML = "Select All";
    }
}

function deselectAllLocations(selectElement) {
    var allLocations = document.getElementById('all_locations');
    if (selectElement.checked == false && allLocations.checked == true) {
        allLocations.checked = false;
        document.getElementById('select_all_label').innerHTML = "Select All";
    }
}
//Search Functions -End
//legacy 
 function NewWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resize=0'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
 }
 
 function NewWindowSendEmail(mypage, myname, w, h, scroll) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    winprops = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl + ',scrollbars=' + scroll + ',resize=0'
    win = window.open(mypage, myname, winprops)
    if (parseInt(navigator.appVersion) >= 4) {
        win.window.focus();
    }
}
function NewWindowAV(mypage, myname, w, h, scroll) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    winprops = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl + ',scrollbars=' + scroll + ',resize=0'
    win = window.open(mypage, myname, winprops)
    if (parseInt(navigator.appVersion) >= 4) {
        win.window.focus();
    }
}

var mediaWindow = '';

function mediaPlayer(PlayerURL,PlayerName,PlayerAttributes) {
    mediaWindow = window.open(PlayerURL,PlayerName,PlayerAttributes);
    mediaWindow.focus();    
}