/*
 *	GENERAL JAVASCRIPT HOWTO
 *	----------------------------------------------------
 *	change - changes the background color of the element
 *	j2 - jump to some page (used mostly in the menu)
 *	popUp - create a popup window of specific size
 *	getSize - get window height in pixels (should be cross-browser compliant)
 *	fixBox - used to make the blog iframe follow the browser window size
 */
function change(e, color) {
	var el = window.event ? event.srcElement: e.target;
	el.style.backgroundColor = color;
}

function menuOver(e) {
	// the color when hovering the mouse on the menu
	change(e,'#996633');
}

function menuOut(e) {
	// the color after moving the mouse from the menu
	change(e,'#CD853F');
}

function j2(url){
	window.location=url;
}
function popUp(url,w,h) { 
  window.open(url,'PopUp',h,w,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0');
}
function getSize() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement &&
		( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return myHeight;
}
function fixBox() {
	minH = 250;
	box = document.getElementById("box");
	if( (getSize()-150)>minH ) {
		box.style.height = getSize()-250+"px";
	}
}

function decryptCharcode(n,start,end,offset)	{
	n = n + offset;
	if (offset > 0 && n > end)	{
		n = start + (n - end - 1);
	} else if (offset < 0 && n < start)	{
		n = end - (start - n - 1);
	}
	return String.fromCharCode(n);
}
// decrypt string
function decryptString(enc,offset)	{
	var dec = "";
	var len = enc.length;
	for(var i=0; i < len; i++)	{
		var n = enc.charCodeAt(i);
		if (n >= 0x2B && n <= 0x3A)	{
			dec += decryptCharcode(n,0x2B,0x3A,offset);	// 0-9 . , - + / :
		} else if (n >= 0x40 && n <= 0x5A)	{
			dec += decryptCharcode(n,0x40,0x5A,offset);	// A-Z @
		} else if (n >= 0x61 && n <= 0x7A)	{
			dec += decryptCharcode(n,0x61,0x7A,offset);	// a-z
		} else {
			dec += enc.charAt(i);
		}
	}
	return dec;
}
// decrypt spam-protected emails
function DecryptMail(s)	{
	location.href = decryptString(s,-3);
}

