// ******************************************************************************************************
// Function to popup url or image in new window
// ******************************************************************************************************
function PopUpGeneric(URL, width, height)
	{
	// Popup window with links to image library. 
	var popleft=((document.body.clientWidth - 440) / 2)+window.screenLeft; 
	var poptop=(((document.body.clientHeight - 460) / 2))+window.screenTop-40;		
	window.open(URL,"_blank","resizable=1,scrollbars=auto,width=" + width + ",height=" + height + ",left="+popleft+",top="+poptop)
	}

// ******************************************************************************************************
// Function that displays wait message when submitting a form
// css-style: .waitMsg {visibility:hidden; color: red; }
// sample code: <span class="waitMsg" ID="id_waitmsg">Loading Data. Please Wait...<br><img id=pbar src="/assets/layout/loading.gif"></span>
// ******************************************************************************************************
function ShowWaitMsg()
{
if(id_waitmsg) id_waitmsg.style.visibility = 'visible';
setTimeout('document.images["pbar"].src = "/assets/layout/loading.gif"', 200);
}

// ***********************************************
// function refreshImg
// Used by the captcha-function to get new image for
// chrome, firefox, opera etc. who doesn't handle the
// cache same way as IE on history.go(-1)
// ***********************************************
function refreshImg(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}

// ******************************************************************************************************
// Function to open help i Editor area
// ******************************************************************************************************
function OpenHelp(){
window.open("/Editor/Editor_help/help.htm","Help","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=990,height=550");
			}

function OpenBgImageLookup(script_name)
	{
	// Popup window with links to image library. 
	var popleft=((document.body.clientWidth - 440) / 2)+window.screenLeft; 
	var poptop=(((document.body.clientHeight - 460) / 2))+window.screenTop-40;		
	window.open(script_name,"_blank","resizable=1,scrollbars=yes,width=480,height=400,left="+popleft+",top="+poptop)
	}

// **********************************
// toggleDiv : Show / Hide functions 
// **********************************
function toggleElement(id) {
 //var e = document.getElementById(id).style.display = '';
 var e = document.getElementById(id);

 if(e.style.display == 'none')
  e.style.display = '';
 else
  e.style.display = 'none';
 }

 // TOGGLE submenu Images
function switchid(id){	
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}
