
function openWindow(theURL,winName,features) {
	var newWin = window.open(theURL,winName,features);
	newWin.window.focus();
}

function closeWindow() {
  var targetWindow = window.self;
  targetWindow.close();
}

function showSweeps() {
	var parentWindow = opener;
	if (parentWindow != undefined && parentWindow.location.pathname != "/Enter.aspx") {
		parentWindow.location.replace("Enter.aspx");
	} else if (parentWindow == undefined) {
		parentWindow = openWindow("Enter.aspx","_blank","left=0,top=0,toolbar=yes,location=yes,menubar=yes,scrollbars=yes,status=yes,resizable=yes,fullscreen=no");
	}
	parentWindow.focus();
}

function openSweeps() {
	var targetWindow = window.self;
	targetWindow.location.replace("Enter.aspx");
}

function showHome() {
	var parentWindow = opener;
	if (parentWindow != undefined && parentWindow.location.pathname != "/index.html") {
		parentWindow.location.replace("index.html");
	} else if (parentWindow == undefined) {
		parentWindow = openWindow("index.html","_blank","left=0,top=0,toolbar=yes,location=yes,menubar=yes,scrollbars=yes,status=yes,resizable=yes,fullscreen=no");
	}
	parentWindow.focus();
}

function openHome() {
	var targetWindow = window.self;
	targetWindow.location.replace("index.html");
}

function openPrivacy() {
	var targetWindow = openWindow("privacy.html","Privacy","width=390,height=600,left=0,top=0,toolbar=no,location=no,menubar=no,scrollbars=yes,status=no,resizable=yes,fullscreen=no");

}

function openRules() {
	var targetWindow = openWindow("rules.html","Rules","width=390,height=600,left=0,top=0,toolbar=no,location=no,menubar=no,scrollbars=yes,status=no,resizable=yes,fullscreen=no");
	targetWindow.focus();
}

function openTAF() {
	var targetWindow = openWindow("tellAFriend.aspx","tellAFriend","width=370,height=390,left=0,top=0,toolbar=no,location=no,menubar=no,scrollbars=no,status=no,resizable=yes,fullscreen=no");
	targetWindow.window.focus();
}

function openVideoPlayer(targetIndex) {
	var targetWindow = openWindow("videoPlayer.html?v=" + targetIndex + "&pageType=videoPlayer","videoPlayer","width=540,height=390,left=0,top=0,toolbar=no,location=no,menubar=no,scrollbars=no,status=no,resizable=yes,fullscreen=no");
	targetWindow.focus();
}

function openViewLarger(targetImg) {
	var targetWindow = openWindow("demoViewLarger.html?img=" + targetImg,"viewLarger","width=600,height=500,left=0,top=0,toolbar=no,location=no,menubar=no,scrollbars=no,status=no,resizable=yes,fullscreen=no");
	targetWindow.focus();
}

function esConfirm(escType) {
	var pageType = "registrationConfirmation_" + escType;
	pageTracker._trackPageview(pageType);
	if (escType == 'checkOut') {
		var targetWindow = window.self;
		targetWindow.location.replace("findYourDayRunner.html");
	} else if (escType == 'viewFull') {
		openWindow("http://catalogs.mwvcooltools.com","_blank","left=0,top=0,toolbar=yes,location=yes,menubar=yes,scrollbars=yes,status=yes,resizable=yes,fullscreen=no");
	} else if (escType == 'tellAFriend') {
		openTAF();
	}
}

function getURLString() {
	// var location_href = window.location.href;
	var location_search = window.location.search;
	if (location_search != null) {
		var startIndex = location_search.indexOf("?");
		var returnString = location_search.slice(startIndex + 1, location_search.length)
		// alert('getURLString: returnString = ' + returnString);
		return returnString;
	} else {
		return;
	}
}
