/*
JavaScript Bookmarking Script
=============================
Developed originally for easy reading of webcomics :D
Feel free to use this script, as far as I am concerned and aware 
the below code is copyright free.

Script Author: Ash Young
Email: ash@evoluted.net
Website: http://evoluted.net/

*/

/*
Config Settings
*/
var cl = 31;
var imgTag = '/includes/yellow/tagmenu/savebutton.gif';
var imgClearOff = '/includes/yellow/tagmenu/clearoffbutton.gif';
var imgGotoOff = '/includes/yellow/tagmenu/homepagegotooffbutton.gif';
var imgClearOn = '/includes/yellow/tagmenu/clearonbutton.gif';
var imgGotoOn = '/includes/yellow/tagmenu/homepagegotoonbutton.gif';
var imgInfo = '/includes/yellow/tagmenu/helpbutton.gif';


/*
Now write out the applicable links
*/
createCookie('t', 1);
var c = readCookie('t');
if(c && document.getElementById) {
	var l = readCookie('bm');
	var gt = imgGotoOff;
	var ct = imgClearOff;
		if(l) {
		gt = imgGotoOn;
		ct = imgClearOn;
	}
	document.write('<a href="#" onClick="gto();return false;"><img src="'+gt+'" alt="Goto Tagged Comic" border="0" id="gtc"></a>');



}

/*
Below are our functions for this little script
*/
function bm() {
	if(document.getElementById) {
		document.getElementById('gtc').src = imgGotoOn;
		document.getElementById('rmc').src = imgClearOn;
	}
	createCookie("bm", window.location, cl);
}

function bmc() {
	if(document.getElementById) {
		document.getElementById('gtc').src = imgGotoOff;
		document.getElementById('rmc').src = imgClearOff;

	}
	createCookie("bm","",-1);
}

function gto() {
	var g = readCookie('bm');
	if(g) {
		window.location = g;
	}	
}

/*
The follow functions have been borrowed from Peter-Paul Koch.
Please find them here: http://www.quirksmode.org
*/
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
