// all common javascript code

var oImg = new Image();

function popupImage(f) {
	
	if (f != null) {
	
		if (f.indexOf(".gif") != -1 ||  
			f.indexOf(".jpg") != -1 || 
			f.indexOf(".bmp") != -1 || 
			f.indexOf(".png") != -1 ||
			f.indexOf(".ico") != -1 ||
			f.indexOf(".jpeg") != -1) {

				oImg.onLoad = pImg1();
				oImg.src = f;	

			} else {
				alert("Sorry, but currently you cannot view media of this type.");
			}
	}
	//return false;
}

function pImg1()
{
	if (!oImg.complete) {
		setTimeout("500,pImg1()");
	}
	else
	{
		setTimeout("500,pImg()");
	}
}

function pImg()
{
try {
	var defaultXsize = (oImg.width + 50);
	var defaultYsize = (oImg.height + 125);
	window.showModalDialog("/Engines/Standard/popupImage.htm", oImg.src, "status:yes; center:yes; help:no; minimize:no; maximize:no; scroll:no; border:thin; statusbar:yes; dialogWidth:" + defaultXsize +"px; dialogHeight:" + defaultYsize + "px");					
	return false;
} catch(e) {alert('Popup blocker detected, please disable your popup blocker to allow the website to function correctly.'); }
}

// pop up video
function popupVideo(f) {
	if (f != null) {
	
		f=f.toLowerCase();
	
		if (f.indexOf(".wmv") != -1 ||  
			f.indexOf(".avi") != -1 || 
			f.indexOf(".mpg") != -1 || 
			f.indexOf(".asf") != -1 || 
			f.indexOf(".asx") != -1 || 
			f.indexOf(".wdl") != -1 || 
			f.indexOf(".wm") != -1 || 
			f.indexOf(".wmx") != -1 || 
			f.indexOf(".wmz") != -1 || 
			f.indexOf(".mpeg") != -1) {

			try {
				window.showModalDialog("/Engines/Standard/popupVideo.htm", f, "status:yes; center:yes; help:no; minimize:no; maximize:no; scroll:no; border:thin; statusbar:yes; dialogWidth:680px; dialogHeight:600px");

			} catch(e) { alert('Popup blocker detected, please disable your popup blocker to allow the website to function correctly.'); }
			//return false;

			} else {
				alert("Sorry, but the video popup cannot play the file: " + f);
			}
	}
}

// switch into print view
function PrintView() {
	var i = window.location.pathname.indexOf("/Print/");
	if (i>=0) {
		document.location.href = window.location.pathname.replace('/Print','') + window.location.search;
	} else {
		document.location.href = '/Print' + window.location.pathname + window.location.search;
	}	
}

//Popups
function showWarning(msg) {
	try	{
	window.showModalDialog("/Engines/System/Sys_Warning.htm",msg,"dialogHeight: 334px; dialogWidth: 400px; edge: Raised; scroll: no; center: Yes; help: No; resizable: No; status: yes;");
	} catch(e) {alert('Popup blocker detected, please disable your popup blocker to allow the website to function correctly.');}
}

function showResults(msg,success) {
	var r = msg + '|' + success + '|';
	try	{
	window.showModalDialog("/Engines/System/Sys_Results.htm",r,"dialogHeight: 334px; dialogWidth: 400px; edge: Raised; scroll: no; center: Yes; help: No; resizable: No; status: yes;");
	} catch(e) {alert('Popup blocker detected, please disable your popup blocker to allow the website to function correctly.');}
}

function showConfirm(msg) {
try	{
	if (window.showModalDialog("/Engines/System/Sys_Confirm.htm",msg,"dialogHeight: 334px; dialogWidth: 400px; edge: Raised; scroll: no; center: Yes; help: No; resizable: No; status: yes;")) {
		return true;
	} else {
		return false;
	}
	} catch(e) {alert('Popup blocker detected, please disable your popup blocker to allow the website to function correctly.');}
}

function showPrompt(msg) {
try	{
	var response = window.showModalDialog("/Engines/System/Sys_Prompt.htm",msg,"dialogHeight: 200px; dialogWidth: 400px; edge: Raised; scroll: no; center: Yes; help: No; resizable: No; status: yes;");
	if (response) {
		return response;
	} else {
		return false;
	}
	} catch(e) {alert('Popup blocker detected, please disable your popup blocker to allow the website to function correctly.');}
}