/* set style cookie */
function styleForm(y) {
	var fface;
	var fsize;
	var colours;
	var x=document.getElementById("stylePick");

	if (x.face[0].checked) fface = "1";
	else if (x.face[1].checked) fface = "2";
	else if (x.face[2].checked) fface = "3";
	else fface = "4";

	if (x.size[0].checked) fsize = "0";
	else if (x.size[1].checked) fsize = "1";
	else if (x.size[2].checked) fsize = "2";
	else if (x.size[3].checked) fsize = "3";
	else fsize = "4";
	
	if (x.color[0].checked) colours = "1";
	else if (x.color[1].checked) colours = "2";
	else if (x.color[2].checked) colours = "3";
	else if (x.color[3].checked) colours = "4";
	else if (x.color[4].checked) colours = "5";
	else colours = "6";

	var the_style = fface + fsize + colours;
	var expdate = new Date();
	expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
    var the_cookie = "swap_style=" + escape("scheme:" + the_style) + ";expires=" + expdate.toGMTString() + ";path=/";
    document.cookie = the_cookie;
	self.location = self.location;
}

/* style preview */
function stylePrev(type, val) {
	var thePara = document.getElementById("stylepreview");
	if (type == "a") {
		if (val == "1") {
			thePara.style.fontFamily = "verdana,arial,helvetica,sans-serif";
		} else if (val == "2") {
			thePara.style.fontFamily = "georgia,'times new roman',serif";
		} else if (val == "3") {
			thePara.style.fontFamily = "'comic sans MS',sans-serif";
		} else if (val == "4") {
			thePara.style.fontFamily = "'Gill Sans MT', 'Gill sans', 'Trebuchet ms', sans-serif";
		}
	}
	else if (type == "b") {
		if (val == "0") {
			thePara.style.fontSize = "9px";
		} else if (val == "1") {
			thePara.style.fontSize = "11px";
		} else if (val == "2") {
			thePara.style.fontSize = "13px";
		} else if (val == "3") {
			thePara.style.fontSize = "16px";
		} else if (val == "4") {
			thePara.style.fontSize = "19px";
		}
	}
	else if (type == "c") {
		if (val == "1") {
			thePara.style.color = "#000";
			thePara.style.backgroundColor = "#FFF";
		} else if (val == "2") {
			thePara.style.color = "#000";
			thePara.style.backgroundColor = "#F6F6F6";
		} else if (val == "3") {
			thePara.style.color = "#000";
			thePara.style.backgroundColor = "#E4E9EF";
		} else if (val == "4") {
			thePara.style.color = "#009";
			thePara.style.backgroundColor = "#FFC";
		} else if (val == "5") {
			thePara.style.color = "#FFF";
			thePara.style.backgroundColor = "#009";
		} else if (val == "6") {
			thePara.style.color = "#FFF";
			thePara.style.backgroundColor = "#000";
		}
	}
}

/* set style form */
function setStyleForm() {
	if (document.cookie) {
		var x=document.getElementById("stylePick");
		var dc = getCookie("swap_style");
		if (dc == null || dc =="")	{
			x.face[0].checked = "true";
			x.size[1].checked = "true";
			x.color[0].checked = "true";
		}
		if (dc != null && dc != "") {
			var split_dc = dc.split(":");
			var the_style = split_dc[1]; 
			var faceval = the_style.charAt(0);
			var sizeval = the_style.charAt(1);
			var colval = the_style.charAt(2);
			faceval = faceval - 1;
			colval = colval - 1;
			x.face[faceval].checked = "true";
			x.size[sizeval].checked = "true";
			x.color[colval].checked = "true";
		} else {
			x.face[0].checked = "true";
			x.size[1].checked = "true";
			x.color[0].checked = "true";
		}
	}
}