// Simplified Popup
// Usage: <a onclick="return popUp(this.href,250,250);" href="popup.aspx">Link</a>
function popUp(theLink, popUpWidth, popUpHeight) {
	var popUpWindow = window.open(theLink, "popUp", "width=" + popUpWidth +
	", height=" + popUpHeight +
	", left=50, top=50, resizable=yes, scrollbars=yes", false);
	if ( popUpWindow != null ) {
		popUpWindow.focus();
	}
	return false;
}
function closePopUp() {
window.close();
}
function closeSurveyPopUp() {
	// Cookie setter
	var expireDate = new Date();
	expireDate.setMonth(expireDate.getMonth() + 6);
	document.cookie = "hasClicked=True;expires=" + expireDate.toGMTString() + ";path=/;";
	document.getElementById("SurveyPopUp").style.display = "none";
}
// Cookie getter
function getCookieValue() {
	var cookieName = "hasClicked";
	var cookieValue = document.cookie;
	var cookieStartsAt = cookieValue.indexOf(" " + cookieName + "=");
	if (cookieStartsAt == -1) {
		cookieStartsAt = cookieValue.indexOf(cookieName + "=");		
	}
	if (cookieStartsAt == -1) {
		cookieValue = null;	
	}
	else {	
		cookieStartsAt = cookieValue.indexOf("=", cookieStartsAt) + 1;
		var cookieEndsAt = cookieValue.indexOf(";", cookieStartsAt);
		if (cookieEndsAt == -1) {
			cookieEndsAt = cookieValue.length;
		}
		cookieValue = unescape(cookieValue.substring(cookieStartsAt, cookieEndsAt));
	}
	return cookieValue;
}
// Survey Psuedo-Popup
function showSurveyPopUp() {
	var hasClicked = getCookieValue();
	if (hasClicked == null) {		
		document.getElementById("SurveyPopUp").style.display = "block";
	}
}
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
			window.onload = function() {
			oldonload();
			func();
		}
	}
}