var pc,mac,ns,ns6,ie
navigator.appVersion.toLowerCase().indexOf('mac') != -1 ? (mac=true) : (pc=true);
navigator.appName.indexOf('Netscape') != -1 ? (ns=true) : (ie=true);
ns6 = navigator.userAgent.indexOf('Netscape6/') > 0 ? 1 : 0;
ie5 = (navigator.userAgent.indexOf('MSIE 5') > 0 || navigator.userAgent.indexOf('MSIE 6') > 0) ? 1 : 0;

if(document.layers){
	document.write('<link rel="stylesheet" type="text/css" href="/include/global_netscape.css">');
	netscape_stylesheet = true;
}
if(mac && (!ns6 && !ie5)){
	document.write('<link rel="stylesheet" type="text/css" href="/include/global_mac.css">');
	mac_stylesheet = true;
}

function donothing() {} 
function gotosite(site) {            
	if (site != "") {                    
		self.location=site; 
	}
 }
function goBack(){
	history.go(-1);
}
function mailTo(whom,whom2){
	document.location = "mai" + "lto" + ":" + whom + whom2 + "&#064;" + "cortlandreview" + "." + "com";
}

////////////////////////////////////////////////
// SUBMISSION PAGE FUNCTIONALITY
////////////////////////////////////////////////

function removeBadChars(str){
	str = str.replace(/[“”]/,"\"");
	str = str.replace(/[‘’`]/,"'");
	str = str.replace(/[—]{1,2}/,"--");
	str = str.replace(/[…]/,"...");
	str = str.replace(/(([ ]*)([-]{2,4}|[—]{1,2})([ ]*))|([ ]+[-–][ ]+)/, "--")
	return str;
}
function validate_submission(){
	if(navigator.userAgent.indexOf("Gecko") < 0) return;
	var re = new RegExp(/[“”‘’`—…]/);
	var thecover = document.forms["subform"].elements["CoverLetter"];
	var newcover = thecover.value;
	while(re.test(newcover)){
		newcover = removeBadChars(newcover);
	}
	thecover.value = newcover;
	for(i=1;i<(submission_boxes+1);i++){
		var thesub = document.forms["subform"].elements["Submission" + i];
		var thetitle = document.forms["subform"].elements["title" + i];
		var newsub = thesub.value;
		var newtitle = thetitle.value;
		while(re.test(newsub)||re.test(newtitle)){
			newsub = removeBadChars(newsub);
			newtitle = removeBadChars(newtitle);
		}
		thesub.value = newsub;
		thetitle.value = newtitle;
	}
	return true;
}

function closesub(){
	if(confirm("Are you sure you want to submit?  TCR is currently closed to unsolicited submissions until September 2003.  Proceed ONLY if we specifically asked you to submit the work you are submitting.  Otherwise please click CANCEL, or we will be forced to discard your submission.")){
		return true;
	} else {
		return false;
	}
}

/*
if(navigator.userAgent.indexOf("Gecko") > 0){
	alert("We have detected that you are using Netscape 6.x as your internet browser.  Please be aware that many users have experienced problems using this form with Netscape 6.x.\n\nWhile you may attempt to submit work with Netscape 6.x, we strongly urge you to use a different browser (such as Internet Explorer) for your submission, at least until such time as we are able to modify the functionality of this submission form for Netscape 6.x.\n\nPlease contact us at TCR@cortlandreview.com if you have any questions.\n\nThank You\nThe Cortland Review");
}
*/


/* HOME PAGE POPUP SCRIPT
function popwin(){
	window.open('http://www.cortlandreview.com/popup.html','message','width=320,height=320');
}
function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
	}
	return null;
}
function SetCookie (name,value,expires,path,domain,secure) {
	document.cookie = name + "=" + escape (value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}
function DeleteCookie (name,path,domain) {
	if (GetCookie(name)) {
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}
var exp = new Date();
exp.setTime(exp.getTime() + (365*24*60*60*1000));
function popWinC() {
	var popval = GetCookie('seenpop');
	if (popval == null) {
		popval=1;
		SetCookie('seenpop', popval, exp, "/");
		var test = GetCookie('seenpop');
		if (test != null){
			popwin();
		}
	}
}	
	
popWinC();
*/

