<!--

/*

	The content structure can be altered,
	with sections opened or closed.

	This JS file handles the structure, image overs,
	and division visibility.
		
	We store a cookie to remember the structure,
	and reload it, each page.

		
*/


	divArray = [0,0,1,1,0,1,1,1];


	function Get_Cookie(name){
		var start = document.cookie.indexOf(name+"=");
		var len = start+name.length+1;
		if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
		if (start == -1) return null;
		var end = document.cookie.indexOf(";",len);
		if (end == -1) end = document.cookie.length;
		return unescape(document.cookie.substring(len,end));
		}


	function Set_Cookie(name,value,expires,path,domain,secure){

		document.cookie = name + "=" +escape(value) +
			";expires=Thu, 01-Jan-2050 00:00:01 GMT" +
			";path=/;domain=fantasyrole.org";

		}


	function Delete_Cookie(name,path,domain){
		if (Get_Cookie(name)){
			document.cookie = name + "=" +
				"expires=Thu, 01-Jan-2000 00:00:01 GMT" +
				";path=/;domain=fantasyrole.org";
			}
		}


/* for new look */

	function CIR(image_id, status){
		if (status==0){
			document.getElementById("contBut" + image_id).src = "/images/headers/but1/but_" + image_id + ".gif";
			}
		else{
			document.getElementById("contBut" + image_id).src = "/images/headers/but1/but_" + image_id + "_on.gif";
			}
		}


	function CIR_dark(image_id, status){
		if (status==0){
			document.getElementById("contBut" + image_id).src = "/images/headers/but1/dark/but_" + image_id + ".gif";
			}
		else{
			document.getElementById("contBut" + image_id).src = "/images/headers/but1/dark/but_" + image_id + "_on.gif";
			}
		}


	function showDiv(this_div){

		strExt = "";

		this_div_state = divArray[this_div]
		this_img_name = "imgExpand" + this_div
		this_div_name = "divExpand" + this_div


		if (this_div_state==0){
			divArray[this_div] = 1;
			document.getElementById(this_div_name).style.display = "block";
			this_img_url = "/images/icon/icon_cont_close" + strExt + ".gif"
			}
		else{
			divArray[this_div] = 0;
			document.getElementById(this_div_name).style.display = "none";
			this_img_url = "/images/icon/icon_cont_open" + strExt + ".gif"
			}
		document.getElementById(this_img_name).src = this_img_url;


		Set_Cookie("dev_frpref",divArray)

		}



	function checkCont(){

		if (Get_Cookie("dev_frpref")){

			storePref = Get_Cookie("dev_frpref")
			storeArray = storePref.split(",")

			for(loop_i=0;loop_i<=divArray.length;loop_i++){

				this_div_name = "divExpand"+loop_i

	/*		

		Check if cookie stores the content structure;
		The division must exist on page, before open/close;
		0 = Open; 1 = closed
		
	*/

				if (document.getElementById(this_div_name)){
					strExt = "";
					this_img_name = "imgExpand"+loop_i

					if (storeArray[loop_i]==1){
						divArray[loop_i] = 1;
						document.getElementById(this_div_name).style.display = "block";
						this_img_url = "/images/icon/icon_cont_close" + strExt + ".gif"
						}

					if (storeArray[loop_i]==0){
						divArray[loop_i] = 0;
						document.getElementById(this_div_name).style.display = "none";
						this_img_url = "/images/icon/icon_cont_open" + strExt + ".gif"
	
						}
					document.getElementById(this_img_name).src = this_img_url;
					}

				}

			}
		}



	function showImage(this_div, method){
		strExt = ""
		if (method==1) strExt+="_hover";
		this_div_state = divArray[this_div];
		this_img_name = "imgExpand" + this_div;
		if (this_div_state==1) this_img_url = "/images/icon/icon_cont_close" + strExt + ".gif"; else this_img_url = "/images/icon/icon_cont_open" + strExt + ".gif";
		document.getElementById(this_img_name).src = this_img_url;
		}

	divArraySP_Pos = 0;
	function addContSub(tvar_id){

// if the content already exists, then do not worry here

		sub_cont_found = 0

		if (divArraySP_Pos!=0){
			for (loop_i=0; loop_i<(divArraySP_Pos); ++loop_i){
				if (divArraySP_1[loop_i]==tvar_id){
					sub_cont_found = 1;
					}
				}
			}

		if (sub_cont_found==0){
			divArraySP_1[divArraySP_Pos] = tvar_id;	// position
			divArraySP_2[divArraySP_Pos] = 0;	// status
			divArraySP_Pos ++;
			}
		}


	divArraySP_1 = [];	// holds the id
	divArraySP_2 = [];	// holds the on/off value

	function showImageSP(this_div, method){
		strExt = "";
		if (method==1) strExt+="_hover";

	// search for the SP div variable

		this_sub = -1; this_div_state = 0;
		for (loop_i=0; loop_i<(divArraySP_Pos); ++loop_i){
			if (divArraySP_1[loop_i]==this_div){
				this_div_state = divArraySP_2[loop_i];
				}
			}
	
		this_img_name = "imgExpand_SP" + this_div;
		if (this_div_state==1) this_img_url = "/images/icon/icon_cont_close" + strExt + ".gif"; else this_img_url = "/images/icon/icon_cont_open" + strExt + ".gif";
		document.getElementById(this_img_name).src = this_img_url;
		}



	function highDiv(this_div){
		showImage(this_div, 1);
		}


	function unhighDiv(this_div){
		showImage(this_div, 0);
		}


	function showDivSP(this_div){
		var gcs_state = 0;
		var str_new_saver = "";
		for (loop_j=0; loop_j<(divArraySP_Pos); ++loop_j){
			if (divArraySP_1[loop_j]==this_div){
				gcs_state = divArraySP_2[loop_j];
				gcs_pos = loop_j;
				}
			}
		this_img_name = "imgExpand_SP" + this_div;
		this_div_name = "divExpand_SP" + this_div;
		if (gcs_state==0){
			gcs_state = 1;
			document.getElementById(this_div_name).style.display = "block";
			this_img_url = "/images/icon/icon_cont_close" + strExt + ".gif";
			}
		else{
			gcs_state = 0;
			document.getElementById(this_div_name).style.display = "none";
			this_img_url = "/images/icon/icon_cont_open" + strExt + ".gif";
			}
		document.getElementById(this_img_name).src = this_img_url;
		divArraySP_2[gcs_pos] = gcs_state;

		if (Get_Cookie("dev_frprefg")){
			storePref = Get_Cookie("dev_frprefg");
			storeArray = storePref.split(",");
			var cookie_found = 0;
			str_new_saver = "";
			for (loop_n=0; loop_n<storeArray.length; ++loop_n){
				this_cont_set = storeArray[loop_n];
				storeArray_Inner = this_cont_set.split(":");
				this_div_temp = storeArray_Inner[0];
				this_div_state_temp = storeArray_Inner[1];
				if (this_div_temp==this_div){
					this_div_state_temp = gcs_state;
					cookie_found = 1;
					}
				str_new_saver += this_div_temp + ":" + this_div_state_temp + ",";
				}
			if (cookie_found==0){
				str_new_saver += this_div + ":" + gcs_state + ",";
				}
			}
		else{		
			for (loop_m=0; loop_m<divArraySP_Pos; ++loop_m){
				str_new_saver += divArraySP_1[loop_m] + ":" + divArraySP_2[loop_m] + ","
				}
			}
		str_new_saver = str_new_saver.substr(0, str_new_saver.length-1)
		Set_Cookie("dev_frprefg", str_new_saver)
		}


	function checkContSP(){
		if (Get_Cookie("dev_frprefg")){
			storePref = Get_Cookie("dev_frprefg")
			storeArray = storePref.split(",")
			for(loop_i=0;loop_i<storeArray.length;loop_i++){
				var gcs_state=0;
				storeArray_Inner = storeArray[loop_i].split(":")
				this_div_temp = storeArray_Inner[0]
				this_div_name = "divExpand_SP" + this_div_temp
				if (document.getElementById(this_div_name)){
					gcs_state = storeArray_Inner[1]
					strExt = "";
					this_img_name = "imgExpand_SP" + this_div_temp
					if (gcs_state==1){
						new_state = 1;
						document.getElementById(this_div_name).style.display = "block";
						this_img_url = "/images/icon/icon_cont_close" + strExt + ".gif";
						}
					if (gcs_state==0){
						new_state = 0;
						document.getElementById(this_div_name).style.display = "none";
						this_img_url = "/images/icon/icon_cont_open" + strExt + ".gif";
						}

					document.getElementById(this_img_name).src = this_img_url;			
					divArraySP_1[divArraySP_Pos] = this_div_temp;	// position
					divArraySP_2[divArraySP_Pos] = new_state;	// status
					divArraySP_Pos++;
					}
				}
			}
		}


	function highDivSP(this_div){
		showImageSP(this_div, 1);
		}

	function unhighDivSP(this_div){
		showImageSP(this_div, 0);
		}


//-->