var actionCode, timerID, editWindow;

function startTimer(action){
	actionCode = action;
	timerID = window.setTimeout('DisplayItem()', 1000, 'javascript');
}

function stopTimer(){
	window.clearTimeout(timerID);
	timerID = null;
}

function DisplayItem(){
	if (timerID != null)
		window.clearTimeout(timerID);
	
	if (editWindow != null)
		editWindow.close();

	LoadEditFrame(actionCode);
	
}

function LoadEditFrame(item){

	var url = 'Admin/EditItem.aspx?Action=' + item;
	window.parent.frames[0].navigate(url);
}



function MarsPostBack(eventTarget, eventArgument) {
	var theform;

	if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
		theform = document.Form1;
	}
	else {
		theform = document.forms["Form1"];
	}

//	theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
//	theform.__EVENTARGUMENT.value = eventArgument;

	theform.submit();
}

    function ValidateAndShowLoading(controlName){
    
		// Ensure validation is true before showloading.
		if (typeof(Page_ClientValidate) == 'function')
		{
			if (Page_ClientValidate() == false)
			{
				return true;
			}
		}
		
		return ShowLoading(controlName);
		
	}

	function ShowLoading(controlName) {

			
		// First hide any message.
		targetElement = document.all("Form1");
		if (targetElement != null) {
			targetElement.style.display = "none";
			targetElement.style.visibility = "hidden";
		}
		
		// Then display the loading.
		targetElement = document.all(controlName);
		if (targetElement != null) {
			targetElement.style.display = "inline";
			targetElement.style.visibility = "visible";
		}
		
		return true;

}

function displayThumbNail(targetId, srcCntl) {
    var targetCntl = document.getElementById(targetId);
    targetCntl.setAttribute("src", srcCntl.src);
}
    
	


