//file
function file_getExtension(fileN) {
	var lastPos; var pos;
	pos=fileN.indexOf(".");
	lastPos=pos;
	
	while (pos != -1) {   
		pos=fileN.indexOf(".",pos+1);
		if (pos != -1) lastPos = pos;
	}
	return fileN.substring(lastPos + 1);
}

//image
ns6 = (document.getElementById)? true:false
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function hideDiv(divName) {
	if (ns4) document.layers[divName].visibility = "hide";
	else if (ns6) document.getElementById(divName).style.visibility = "hidden";
	else if (ie4) document.all[divName].style.visibility = "hidden";
}

function showDiv(divName) {
    if (ns4) document.layers[divName].visibility = "show";
	else if (ns6) document.getElementById(divName).style.visibility = "visible";
	else if (ie4) document.all[divName].style.visibility = "visible";
}



function showProv(Prov_id) {
	for(i=1;i<17;i++) { 
		//hideDiv('Prov_' + i);
		hideDiv('provMap_' + i);
	}

	//showDiv('prov_' + Prov_id);
	showDiv('provMap_' + Prov_id);
}

function getSWFCode(imageFileName, imagesFolder, imageWidth, imageHeight) {
    return "<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" WIDTH=\""+imageWidth+"\" HEIGHT=\""+imageHeight+"\"><PARAM NAME=movie VALUE=\""+imagesFolder+"/" + imageFileName + "\"> <PARAM NAME=quality VALUE=high> <param name=\"wmode\" value=\"transparent\" /> <EMBED src=\""+imagesFolder+"/" + imageFileName + "\" quality=high wmode=\"transparent\" WIDTH=\""+imageWidth+"\" HEIGHT=\""+imageHeight+"\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></EMBED></OBJECT>";
}


function showImage(imageFileName, imagesFolder, imageWidth, imageHeight){
	if (file_getExtension(imageFileName).toUpperCase() == 'SWF') {
		var imgText = getSWFCode(imageFileName, imagesFolder, imageWidth, imageHeight);
	} else {
		var imgText = "<img border=0 src=\""+imagesFolder+"/" + imageFileName + "\" width=\""+imageWidth+"\" height=\""+imageHeight+"\">"
	}
	
	document.write(imgText);
}


//email
function writeEmail(email_mailbox, email_host, email_show, email_class) 
{
	// protected email script by Joe Maller
	// JavaScripts available at http://www.joemaller.com
	// this script is free to use and distribute
	// but please credit me and/or link to my site
	// Function created by Michal Borychowski
	emailE=(email_mailbox + '@' + email_host);
	if (!email_show) email_show = emailE;
	if (email_class) email_class = ' class="'+email_class+'"'
	else email_class = '';
	document.write('<a' + email_class + ' href="mailto:' + emailE + '">' + email_show + '</a>');
}


function showMediaPopUpWindow(url, width, height) {
	var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,left=100,top=100');
	Win.focus();
}
