if ( typeof ( rooturl ) == "undefined" )
{
	rooturl = "";
}

helpButton_off = new Image;
helpButton_on = new Image;
helpButton_off.src= "/images/ezine/help_off.gif";
helpButton_on.src= "/images/ezine/help_on.gif";

hideButton_off = new Image;
hideButton_on = new Image;
hideButton_off.src= rooturl + "/images/ezine/hide_off.gif";
hideButton_on.src=rooturl + "/images/ezine/hide_on.gif";

showButton_off = new Image;
showButton_on = new Image;
showButton_off.src=rooturl + "/images/ezine/show_off.gif";
showButton_on.src=rooturl + "/images/ezine/show_on.gif";

send_to_friend_off = new Image;
send_to_friend_on = new Image;
send_to_friend_off.src=rooturl + "/images/send_friend.gif";
send_to_friend_on.src=rooturl + "/images/send_friend_over.gif";

dialog_ok_off = new Image;
dialog_ok_on = new Image;
dialog_ok_off.src=rooturl + "/images/butt_ok_off.gif";
dialog_ok_on.src=rooturl + "/images/butt_ok_on.gif";

function swap(first, second)
{
	first.src = second.src;
}

function newWindow(url, width, height, requireLogin, wname)
{
	// Calculate the screen coordinates to open a new window - window should appear in the middle of the screen
	var left = ((screen.width - width) / 2);
	var top = ((screen.height - height) / 2);
	
	// If window name is not passed in use default value
	if (!wname) {
		wname = "blank";
	}
	// Open new window and then focus on it 
	newWin = window.open(url,wname,"'menubar=no,location=no,resizable=yes,scrollbars=no,status=no,left=" + left + ",top=" + top + ",width=" + width + ",height=" + height + "'");
	if (window.focus) {
		newWin.focus();
	}
}

function capInput (o, n) {
	if (o.value.length > n) {
		o.value = o.value.substring(0,n-1);
		return false;
	}
	return true;
}

function isNotEmpty(obj, name) {
	if (obj.value == "") return "You need to fill in the " + name + " field.\n";
	return "";
}

function isInteger(obj, name, mi, ma) {
	if (mi != null) {
		if (parseInt(obj.value) == obj.value){
			if (obj.value < mi) return name + " must be an integer (whole number) greater than or equal to " + mi + ".\n";
		}
	}
	if (ma != null) {
		if (parseInt(obj.value) == obj.value){
			if (obj.value > ma) return name + " must be an integer (whole number) less than or equal to " + ma + ".\n";
		}
	}
	if (parseInt(obj.value) != obj.value) return name + " must be an integer (whole number).\n";
	return "";
}

function isEmail(obj, name) {
	var val = obj.value;
	if (val.indexOf("@") > 0 && val.indexOf(".") > 0 && val.indexOf("@") < val.lastIndexOf(".") && val.lastIndexOf(".")+1 != val.length && val.lastIndexOf("@") < val.lastIndexOf(".") && val.lastIndexOf("@") == val.indexOf("@") && val.indexOf(" ") == -1) return "";
	return "Sure you got the " + name + " right?\n"; 
}

function closeDialog(element)
{
	document.getElementById(element).style.visibility = "hidden";
}

function doAlert(mystr)
{
	document.getElementById("dialog_text").innerHTML = mystr;
	document.getElementById("popup").style.width=document.body.clientWidth;
	document.getElementById("popup").style.height=document.body.clientHeight;
	document.getElementById("popup").style.visibility = "visible";
}

window.alert = doAlert

function doConfirm(mystr)
{
	document.getElementById("confirm_text").innerHTML = mystr;
	document.getElementById("confirm").style.width=document.body.clientWidth;
	document.getElementById("confirm").style.height=document.body.clientHeight;
	document.getElementById("confirm").style.visibility = "visible";
}

window.confirm = doConfirm

function launchSL(ps,vol,sID,ms){
	slpopup=window.open('/libragirl/soundlounge/soundpopup.jsp','slpopup','height=338,width=380,scrollbars=0');
	//document.sID=sID;
	//document.ms=ms;
	//document.ps=ps;
	//document.vol=vol;
}


var whitespace="\n\r\t ";
var quotes="\"'";
function convertEscapes(str){
	var gt;
	gt=-1;
	while(str.indexOf("&lt;",gt+1)>-1){
		var gt=str.indexOf("&lt;",gt+1);
		var newStr=str.substr(0,gt);
		newStr+="<";
		newStr=newStr+str.substr(gt+4,str.length);
		str=newStr;
	}
	gt=-1;
	while(str.indexOf("&gt;",gt+1)>-1){
		var gt=str.indexOf("&gt;",gt+1);
		var newStr=str.substr(0,gt);
		
		newStr+=">";
		newStr=newStr+str.substr(gt+4,str.length);
		str=newStr;
	}

	gt=-1;
	while(str.indexOf("&amp;",gt+1)>-1){
		var gt=str.indexOf("&amp;",gt+1);
		var newStr=str.substr(0,gt);
		newStr+="&";
		newStr=newStr+str.substr(gt+5,str.length);
		str=newStr;
	}
	
	return str;
}

function convertToEscapes(str){
	var gt=-1;
	while(str.indexOf("&",gt+1)>-1){
		gt=str.indexOf("&",gt+1);
		var newStr=str.substr(0,gt);
		newStr+="&amp;";
		newStr=newStr+str.substr(gt+1,str.length);
		str=newStr;
	}

	gt=-1;
	while(str.indexOf("<",gt+1)>-1){
		var gt=str.indexOf("<",gt+1);
		var newStr=str.substr(0,gt);
		newStr+="&lt;";
		newStr=newStr+str.substr(gt+1,str.length);
		str=newStr;
	}

	gt=-1;
	while(str.indexOf(">",gt+1)>-1){
		var gt=str.indexOf(">",gt+1);
		var newStr=str.substr(0,gt);
		newStr+="&gt;";
		newStr=newStr+str.substr(gt+1,str.length);
		str=newStr;
	}
	
	gt=-1;
	while(str.indexOf("%",gt+1)>-1){
		var gt=str.indexOf("%",gt+1);
		var newStr=str.substr(0,gt);
		newStr+="&#37;";
		newStr=newStr+str.substr(gt+1,str.length);
		str=newStr;
	}
	return str;
}