	var curscreen = null;
	function $e(id)
	{
		return document.getElementById(id);
	}
	function $v(id)
	{
		return $e(id).value;
	}
	String.prototype.trim = function()
	{
		a = this.replace(/^\s+/, '');
		return a.replace(/\s+$/, '');
	};
	String.prototype.isEmail = function()
	{
		if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,5})+$/.test(this))
			return true;
		else
			return false;
	};
	String.prototype.isAlphaNumeric = function () {return /^[a-z\A-Z\d]+$/.test (this)}
	function showLabel()
	{
		if($e(this.id + '_label'))
			$e(this.id + '_label').style.display = 'block';
	}
	function hideLabel()
	{
		if($e(this.id + '_label'))
			$e(this.id + '_label').style.display = 'none';
	}
	function addEvents(ele)
	{
		var list = ele.getElementsByTagName('input');
		for(i=0;i<list.length;i++)
			if($e(list[i].id + '_label'))
			{
				list[i].onfocus = showLabel;
				list[i].onblur = hideLabel;
				$e(list[i].id + '_label').style.display = 'none';
			}
		list = ele.getElementsByTagName('textarea');
		for(i=0;i<list.length;i++)
			if($e(list[i].id + '_label'))
			{
				list[i].onfocus = showLabel;
				list[i].onblur = hideLabel;
				$e(list[i].id + '_label').style.display = 'none';
			}
	}
	function iError(id)
	{
		if($e(id))
		{
			document.getElementById(id).style.backgroundColor = "pink";
			if($e(id + "_label"))
			{
				document.getElementById(id + "_label").style.color = "red";
				$e(id + "_label").style.display = "block";
			}
		}
	}
	function noError(id)
	{
		if($e(id))
		{
			document.getElementById(id).style.backgroundColor = "";
			if($e(id + "_label"))
			{
				document.getElementById(id + "_label").style.color = "";
				$e(id + "_label").style.display = "none";
			}
		}
	}
	function screen(id,flag)
	{
		if(flag)
		{
			if(document.all)
			{
				var body = document.getElementsByTagName('html')[0];
				body.style.height = '100%';
				body.style.overflow = 'hidden';
			}
			else
				document.body.style.overflow = 'hidden';
			scroll(0,0);
			document.getElementById('screen').style.visibility = "visible";
			document.getElementById(id).style.visibility = "visible";
			curscreen = id;
		}
		else
		{
			if(document.all)
			{
				var body = document.getElementsByTagName('html')[0];
				body.style.height = '';
				body.style.overflow = '';
			}
			else
				document.body.style.overflow = '';
			document.getElementById('screen').style.visibility = "hidden";
			document.getElementById(id).style.visibility = "hidden";
			curscreen = '';
		}
	}
	function hidescreen()
	{
		if(curscreen)
			screen(curscreen,0);
	}
	function login()
	{
		var complete = true;
		if(!$v('username'))
		{
			$e('username').style.backgroundColor = 'pink';
			complete = false;
		}
		else
			$e('username').style.backgroundColor = '';
		if(!$v('password'))
		{
			$e('password').style.backgroundColor = 'pink';
			complete = false;
		}
		else
			$e('password').style.backgroundColor = '';
		if(complete)
			$e('formLogin').submit();
	}
	var userid = null;
	function premier(url)
	{
		if(userid != 0)
			window.location = url;
		else
		{
			if(url.indexOf(':'))
				$e('loginFrom').value = url;
			else
				$e('loginFrom').value = '../' + url;
			centerSize('tblLogin','divlogin');
			screen('divlogin',1);
			$e('username').focus();
		}
	}
	//Code to resize the gallery image
	function centerSize(div,container)
	{
		var width = parseInt((parseInt($e(div).offsetWidth)));
		var height = parseInt((parseInt($e(div).offsetHeight)));
		if(document.documentElement && document.documentElement.clientWidth)
			width = parseInt((parseInt(document.documentElement.clientWidth) - width)/2);
		else
			width = parseInt((parseInt(document.body.offsetWidth) - width)/2);
		if(width < 0)
			width = 0;
		if(document.documentElement && document.documentElement.clientHeight)
			height = parseInt((parseInt(document.documentElement.clientHeight) - height)/2);
		else
			height = parseInt((parseInt(document.body.offsetHeight) - height)/2);
		if(height < 0)
			height = 0;
		$e(container).style.left = width + 'px';
		$e(container).style.top = height + 'px';
	}
	function toggle(id)
	{
		if($e(id).style.display == 'block')
			$e(id).style.display = 'none';
		else
			$e(id).style.display = 'block';
	}
	function selectValue(id,value)
	{
		var select = document.getElementById(id).getElementsByTagName("option");
		for(i=0;i<select.length;i++)
			if(select[i].value == value)
				select[i].selected = "selected";
			else
				select[i].selected = null;
	}
	function selectElement(id,ele)
	{
		selectValue(id,document.getElementById(ele).value);
	}
	function getradiovalue(radioname)
	{
		if(!document.getElementsByName(radioname))
			return;
		var ids = document.getElementsByName(radioname);
		for(i=0;i<ids.length;i++)
			if(ids[i].checked)
				return ids[i].value;
		return 0;
	}
	function init()
	{
		$jq('div.contenttop').corner('top 20px');
		$jq('div.contentbottom').corner('bottom 20px');
		$jq('div.greenNote, div.redNote, div.orangeNote, div.blueNote, div.helpNote').corner('bottom 8px').corner('tr dog 10px');
	}

	function rating(id,title)
	{
		if(userid != 0)
		{
			$e('nodeRating').value = id;
			if(title)
				$e('ratingTitle').innerHTML = title;
			centerSize('divrating','divrating');
			screen('divrating',1);
		}
		else
			premier(window.location.href);
	}
	var timetorate = 0;
	function saveRating(rating)
	{
		if(timetorate > 0)
			$e('waitRate').style.display = 'block';
		else
			window.location = 'inc/rating.php?userid=' + userid + '&node=' + $v('nodeRating') + '&rating=' + rating + '&from=' + escape(window.location.href);
	}

	function ratingtimer()
	{
		if(timetorate > 0)
		{
			timetorate--;
			$e('timetorate').innerHTML = timetorate;
			setTimeout(ratingtimer,1000);
		}
		else
			$e('waitRate').style.display = 'none';
	}
	function show(id)
	{
		if($e(id))
			$e(id).style.display = 'block';
	}

	function comment(id,title)
	{
		if(userid != 0)
		{
			if(id)
			{
				$e('nodeComment').value = id;
				$e('editComment').value = '';
			}
			if(title)
				$e('commentTitle').innerHTML = title;
			centerSize('divcomment','divcomment');
			screen('divcomment',1);
		}
		else
			premier(window.location.href);
	}
	var timetocomment = 0;
	function saveComment()
	{
		if(timetocomment > 0)
			$e('waitComment').style.display = 'block';
		else
		{
			$e('formComment').action = 'inc/comment.php?userid=' + userid + '&from=' + escape(window.location.href);
			$e('formComment').submit();
		}
	}

	function commenttimer()
	{
		if(timetocomment > 0)
		{
			timetocomment--;
			$e('timetocomment').innerHTML = timetocomment;
			setTimeout(commenttimer,1000);
		}
		else
			$e('waitComment').style.display = 'none';
	}
