var urbanOnLoad = null;

function body_load() {
	var path = "forIE" + document.location.pathname;
	var ur_nav;
	var arr = path.split(/\//);
	
	if (arr.length < 3) {
		ur_nav = "home";
	} else if (arr.length > 3 && (arr[1] == "ur" || arr[1] == "ur2")) {
		ur_nav = (arr[2] == "workshops" ? "workshops" : "products");
	} else {
		ur_nav = arr[1];
	}

	var temp;	// Safari doesn't like direct assignment of innerHTML values
	temp = document.getElementById("topNavContent").innerHTML;
	document.getElementById("topNavContent").innerHTML = "";
	document.getElementById("topNav").innerHTML = temp;
	
	/*
	temp = document.getElementById("leftNavContent").innerHTML;
	document.getElementById("leftNavContent").innerHTML = "";
	document.getElementById("leftNav").innerHTML = temp;
	*/
	
	var ele = document.getElementById("topNav-" + ur_nav);
	
	if (ele) { 
		ele.id = "selected";		
	} else {
		document.getElementById("topNav-home").id = "selected";
		
	}
	
	//document.getElementsByTagName("body")[0]
    var re = new RegExp('\\b' + 'capsuleimg' + '\\b');
    var els = document.getElementById("right_content").getElementsByTagName("div");
    for(var i=0,j=els.length; i<j; i++) {
        if(re.test(els[i].className)) {
			temp = els[i].innerHTML;
			els[i].innerHTML = "";
			els[i].innerHTML = "<table><tr><td>" + temp + "<br clear='all'></td></tr></table>";
		}
	}
	
	ele = document.getElementById("quicklink");
	if (ele) {
		
		if (ele.innerHTML == "email|register" ||
			(ur_nav == "workshops" && ele.innerHTML != "email" )) {
			temp = document.getElementById("quicklinkContentWorkshops").innerHTML;
			document.getElementById("quicklinkContentWorkshops").innerHTML = "";
		} else {
			temp = document.getElementById("quicklinkContent").innerHTML;
			document.getElementById("quicklinkContent").innerHTML = "";
		}
		ele.innerHTML = temp;
		
		ele.className = "quicklink";
	}
	
	document.getElementById("reusableContent").innerHTML = "";
	
	if (urbanOnLoad != null) urbanOnLoad();
}

navTimer = null;
currentNav = 0;
o_navigator = navigator.userAgent
var isIE5 = (o_navigator.indexOf("MSIE 5") > -1) ? 1 : 0;
var isMac = (o_navigator.indexOf("Mac") > -1) ? 1 : 0;
var isIE50 = (o_navigator.indexOf("MSIE 5.0") > -1) ? 1 : 0;
var isIE52 = (o_navigator.indexOf("MSIE 5.2") > -1) ? 1 : 0;
var isNN6 = (o_navigator.indexOf("Netscape6") > -1) ? 1 : 0;
var isDOM = (document.getElementById) ? 1 : 0;

function mainNavOver(o_div){
	if(isDOM&&!isNN6&&!isIE52&&!isIE50){
		if(currentNav)clearNavOver();
		clearTimeout(navTimer);
		setNavOver(o_div);
	}
}
function mainNavOut(o_div){
	if(isDOM&&!isNN6&&!isIE52&&!isIE50){
		currentNav = o_div;
		navTimer = setTimeout('clearNavOver()',1);
	}
}
function setNavOver(o_div) {
	if (o_div.id != "selected") {
		document.getElementById("selected").className="navHide";
	}
	o_div.className="navOver";
}
function clearNavOver() {
	document.getElementById("selected").className="";
	currentNav.className="";
}

function launchWindow(url,w,h){
	winName = "_new"
	if (!h)popHeight = screen.availHeight - 100;
	else popHeight = h;
	winParams = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' + w + ',height=' + popHeight;
	newwin = window.open(url, winName, winParams);
	newwin.focus();
}

function sendtofriend(sTitle, sSummary) {
	//alert(sTitle+" "+ sSummary);
	
	if (typeof sTitle != 'undefined') document.sendtofriend2.WSTitle.value = sTitle;
	if (typeof sSummary != 'undefined') document.sendtofriend2.WSSummary.value = sSummary;
	
	document.sendtofriend2.WSLink.value = top.location.href;
	document.sendtofriend2.method = "post";
	document.sendtofriend2.action = "/ur/workshops/sendtofriend.aspx";
	document.sendtofriend2.submit();
	
}

var quickfrm = document.quickMailingList;

function QuickDoContinue() {	
	if(quickfrm.Email.value == ""){ alert("Please enter your Email address.");
		quickfrm.Email.focus(); return false; }
	if(!QuickValidateEmail(quickfrm.Email.value)){ alert("Please enter the Email in the following format: student@myplace.com");
		quickfrm.Email.focus(); return false; } 
	//alert("*" + quickfrm.City1.value + "*");
	if(quickfrm.City1.value == " "){ alert("Please select the city closest to you");
		quickfrm.City1.focus(); return false; }
	
	
	return true;
	//return false;
}

function QuickValidateEmail(sEmail) {
	var validFormatRegExp = /^\w(\.?[\w-])*@\w(\.?[-\w])*\.[a-z]{2,4}$/i;
	var isValid = validFormatRegExp.test(sEmail);
	return isValid;
}
