var width = 795
var height = 400

function viewDatabase(index) {
	var database = window.open("/cgi-bin/info.pl?mode=display&infoID=" + index, "Database", "width=450,height=320,scrollbars=yes");
}

function viewAvatar() {
	var avatarWindow = window.open("/cgi-bin/avatar_info.pl?avatarURI=" + document.forms[0].character.value, "AvatarWindow", "width=625,height=320,scrollbars=yes");
	avatarWindow.focus();
}

function viewSPAvatar() {
	var avatarWindow = window.open("/cgi-bin/avatar_info.pl?avatarURI=" + document.forms[0].SPcharacter.value, "AvatarWindow", "width=625,height=320,scrollbars=yes");
	avatarWindow.focus();
}

function openCredits() {
	var credits = window.open("/credits", "Credits", "height=350,width=630,toolbar=yes,scrollbars=yes");
}

function openProfile() {
	var dossiers = window.open("/cgi-bin/profile.fcgi", "Profile", 'height=' + height + ',width=' + width + ',toolbar=yes,menubar=yes,location=yes,resizable=yes,top=0,left=0,scrollbars=yes');
}

function openRegister() {
	var register = window.open("/cgi-bin/register.pl", "Register", 'height=' + height + ',width=' + width + ',toolbar=yes,menubar=yes,location=yes,resizable=yes,top=0,left=0,scrollbars=yes');
}

function openPrimeDirectives() {
	var pds = window.open("/doc/prime_directives.shtml", "PDs", 'height=' + height + ',width=' + width + ',toolbar=yes,menubar=yes,location=yes,resizable=yes,top=0,left=0,scrollbars=yes');
}

function openPromotions() {
	var promotions = window.open("/doc/promotions.shtml", "Promotions", 'height=' + height + ',width=' + width + ',toolbar=yes,menubar=yes,location=yes,resizable=yes,top=0,left=0,scrollbars=yes');
}

function emailSTSC() {
	var stsc = window.open("/cgi-bin/mail.pl?mailToName=Star%20Trek%20Sector%20Command&mailToEmail=sector-st@admin.outpost10f.com", "STSC", 'height=' + height + ',width=' + width + ',toolbar=yes,menubar=yes,location=yes,resizable=yes,top=0,left=0,scrollbars=yes');
}

function emailSTDSC() {
	var stdsc = window.open("/cgi-bin/mail.pl?mailToName=Star%20Trek%20Sector%20Command&mailToEmail=sector-st@admin.outpost10f.com", "STDSC", 'height=' + height + ',width=' + width + ',toolbar=yes,menubar=yes,location=yes,resizable=yes,top=0,left=0,scrollbars=yes');
}

function emailSWSC() {
	var swsc = window.open("/cgi-bin/mail.pl?mailToName=Star%20Wars%20Sector%20Command&mailToEmail=sector-sw@admin.outpost10f.com", "SWSC", 'height=' + height + ',width=' + width + ',toolbar=yes,menubar=yes,location=yes,resizable=yes,top=0,left=0,scrollbars=yes');
}

function emailSWDSC() {
	var swdsc = window.open("/cgi-bin/mail.pl?mailToName=Star%20Wars%20Sector%20Command&mailToEmail=sector-sw@admin.outpost10f.com", "SWDSC", 'height=' + height + ',width=' + width + ',toolbar=yes,menubar=yes,location=yes,resizable=yes,top=0,left=0,scrollbars=yes');
}

function emailLRSC() {
	var fysc = window.open("/cgi-bin/mail.pl?mailToName=LOTR%20Sector%20Command&mailToEmail=sector-lotr@admin.outpost10f.com", "LRSC", 'height=' + height + ',width=' + width + ',toolbar=yes,menubar=yes,location=yes,resizable=yes,top=0,left=0,scrollbars=yes');
}

function emailLRDSC() {
	var fydsc = window.open("/cgi-bin/mail.pl?mailToName=LOTR%20Sector%20Command&mailToEmail=sector-lotr@admin.outpost10f.com", "LRDSC", 'height=' + height + ',width=' + width + ',toolbar=yes,menubar=yes,location=yes,resizable=yes,top=0,left=0,scrollbars=yes');
}

function openUpdates(genre) {
	var updates = window.open("/cgi-bin/updates.fcgi?aff=" + genre, "Updates", "height=400,width=790,toolbar=yes,scrollbars=yes");
}

function openCCCMovie() {
	var movie = window.open("/ccc/ccc_movie.html", "movie", "height=400,width=700");
}

function chatPreview() {
	document.forms[0].action="/cgi-bin/chatpreview.pl";
	document.forms[0].submit();
	document.forms[0].action="/cgi-bin/login.fcgi";
}

 //////////////////////////////////
//                               //
//     OTF Login Cookie 2.0      //
//    ======================     //
//                               //
//   by Joshua T. Hal            //
//   joshua_hal@outpost10f.com   //
//                               //
//   last updated on 28.2.2000   //
//                               //
//   Update: 2009-09-06 (Iain)   //
/// -- browser compatibility     //
//                               //
//////////////////////////////////

function loadValues(form, separator) {
	if(!window.document.cookie) alert("Error:\nCookie not found.");
	else {
		//var cookies = window.document.cookie.split("; ");
		var cookies = window.document.cookie.split(";");
		var cookie = "";
		for(var i = 0; i < cookies.length; i++)
			if(cookies[i].substring(0, cookies[i].indexOf("=")) == form.name)
				cookie = cookies[i];
		if(cookie == "") alert("Error:\nCookie not found.");
		else {
			cookie = cookie.substring(cookie.indexOf("=") + 1);
			var values = cookie.split(separator);
			for(var i = 0; i < form.elements.length; i++) {
				if((form.elements[i].type == "text")
				|| (form.elements[i].type == "textarea")) form.elements[i].value = values[i];
				else if(((form.elements[i].type == "checkbox")
				|| (form.elements[i].type == "radio")) && (values[i] == "1")) form.elements[i].checked = true;
				else if(form.elements[i].type == "select-one") form.elements[i].selectedIndex = values[i];
			}
		}
	}
}

function saveValues(form, separator, lifespan_in_days) {
	var cookie = form.name + "=";
	var date = new Date();
	date.setTime(date.getTime() + (1000 * 60 * 60 * 24 * lifespan_in_days));
	for(var i = 0; i < form.elements.length; i++) {
		if(i != 0) cookie += separator;
		if((form.elements[i].type == "text")
		|| (form.elements[i].type == "textarea")) cookie += form.elements[i].value;
		else if((form.elements[i].type == "checkbox")
		|| (form.elements[i].type == "radio")) cookie += form.elements[i].checked ? "1" : "0";
		else if(form.elements[i].type == "select-one") cookie += form.elements[i].selectedIndex;
	}
	window.document.cookie = cookie + "; expires=" + date.toGMTString();
	if(!window.document.cookie) alert("Error:\nUnable to save cookie.");
	else {
		var saved = false;
		//var cookies = window.document.cookie.split("; ");
		var cookies = window.document.cookie.split(";");
		for(var i = 0; i < cookies.length; i++)
			if(cookies[i] == cookie) saved = true;
		if(saved) alert("Your data has been saved.");
		else alert("Error:\nUnable to save cookie.");
	}
}

function showImage(avatarSrc) {
   	document.images.useravatars.src = avatarSrc;
}

function updateAvShowImage(avatarSrc) {
   	document.images.useravatars.src = avatarSrc;
	document.forms[0].specialPic.value = avatarSrc;
}

function changeImageLink(avatar) {
	document.links[avatarLink].href = "http://www.outpost10f.com/cgi-bin/avatar_info.pl?avatarID=" + avatar;
	document.links[12].href = "#" + " onMouseDown=\"javascript:viewAvatar(" + avatarSrc + ");";

}
