function obj(objname){
	return document.getElementById(objname);
}

function onDeleteImage(imageid){
	var r = confirm("Are you sure you want to remove this image from PhotoBlink?");
	if(!r){
		return;		
	}
	obj("deleteform").removeimage.value = imageid;
	obj("deleteform").submit();	
}

function doAddImToPPage(imageID, iconID, useForms){
	if(useForms == "yes"){
		obj("ppform").ppImageID.value = imageID;
		obj("ppform").submit();
		return;
	}
//alert("doAddImToPPage entered. current imageID=" + imageID + ". IconID=" + iconID.id);
//return;	
	floatMessage("please wait...", tooltip);
	window.setTimeout("addImToPPage(" + imageID + ", " + iconID.id + ")", 10);		
}

function addImToPPage(imageID, iconID){
// alert("addImToPPage entered current imageID=" + imageID);
// iconID.src = "design/page.gif"
// iconID.style.cursor = ""
// return;
	try{
		errMess = AddImage(imageID);
//errMess = AddImage(0);
	}catch(e){
		msg = "Error occured. If you have this message often\n " +
				"please consider changing your scoring/commenting method \n " +
				" from the 'My PhotoBlink' page ";
		unfloatMessage(tooltip);
		alert(msg);
		return;	
	}

	if(errMess){
		alert(errMess);
		unfloatMessage(tooltip);
		return;
	}

 	unfloatMessage(tooltip);
	floatMessage("The image has been successfully added to your personal page", tooltip);
	window.setTimeout("unfloatMessage(tooltip)", 1000);
	iconID.src = "design/page.gif"
	iconID.style.cursor = ""
}

function AddImage(imageID){
	source = new ActiveXObject("Microsoft.XMLDOM");
	source.async = false;		//Don't forget to set this

	pageRef = "addImToPPage.asp";
	pageRef += "?ppImageID="+imageID;

	source.load(pageRef);
	
	var errMess, imageName;
	var vals, data

	data = source.selectSingleNode("data");	
	vals = data.childNodes;
	i = 0;
	errMess = vals(i++).text;
	errStat = vals(i++).text;
	errSource = vals(i++).text;
	imageName = vals(i++).text;

	if (errStat != "0") 
		return errMess + " (occured in " + errSource + ")";

}
//*******************************************	
ie4 = document.all;
nn4 = document.layers;
ver4 = ie4 || nn4;
currScoreElem = null;


function checkVote(myForm, vote){
	if(!isNum(vote))
		alert("Input a number");
	else
		myForm.submit();
}


function show(object, mouse) {
	if(!object || !mouse)
		return;
	var p = obj(object);
	var left = mouse.clientX - p.offsetWidth - 10;
	if(left < 0)
		left = mouse.clientX + 10;
	p.style.visibility = 'hidden';
	p.style.left = left + window.document.body.scrollLeft;
	p.style.top = mouse.clientY - 5 + window.document.body.scrollTop;
	p.style.visibility = 'visible';	
}

function hide(object) {
	if(!object)
		return;
	obj(object).style.visibility = 'hidden';
}


// function quickView(url, name, w, h)
// {
// 	var wndprop = "scrollbars,resizable";
// 	popupWin = window.open(url, name, wndprop, false)
// 	popupWin.resizeTo(w + 50, h + 105);
// }

function changeview(val, querystring){
	var rowNumForm = obj("rowNumForm");
	rowNumForm.classicview.value = val;
	//alert(rowNumForm.querystring);
	//alert(rowNumForm.querystring.value);	
	rowNumForm.submit();
}

