// used to preload image files
var imageArray = new Array();

// browser detection used by findDOM
var isDHTML = 0;
var isID = 0;
var isAll = 0;
var isLayers = 0;

if (document.getElementById) {isID = 1; isDHTML = 1;}
else {
if (document.all) {isAll = 1; isDHTML = 1;}
else {
browserVersion = parseInt(navigator.appVersion);
if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {isLayers = 1; isDHTML = 1;}
}}

function findDOM(objectID,withStyle) {
	if (withStyle == 1) {
		if (isID) {
			if (document.getElementById(objectID))
				return (document.getElementById(objectID).style);
			else
				return (null);
		}
		else { 
			if (isAll) {
				if (document.all[objectID])
					return (document.all[objectID].style);
				else
					return (null);
			}
		else {
			if (isLayers) { return (document.layers[objectID]); }
		};}
	}
	else {
		if (isID) {
			return (document.getElementById(objectID));
		}
		else { 
			if (isAll) {
				return (document.all[objectID]);
			}
			else {
				if (isLayers) {
					return (document.layers[objectID]);
				}
			}
		}
	}
}

function resizeImage(domImg, img, imgName, targetHeight, targetWidth) {
	var newHeight = img.height;
	var newWidth = img.width;
	if ((newHeight > targetHeight) || (newWidth > targetWidth)) {
		var heightMultiplier = img.height / targetHeight;
		var widthMultiplier = img.width / targetWidth;
		if (heightMultiplier > widthMultiplier) {
			newHeight = img.height / heightMultiplier;
			newWidth = img.width / heightMultiplier;
		}
		else {
			newHeight = img.height / widthMultiplier;
			newWidth = img.width / widthMultiplier;
		}
	}
	domImg.height = newHeight;
	domImg.width = newWidth;
}
function resizeImages() {
	if (imageArray) {
		for( i=1; i<=imageArray.length; i++) {
			var domImg = findDOM("img"+i,0);
			if (domImg) {
				resizeImage(domImg, imageArray[i], "img"+i, 151, 99);
			}
		}
	}
}

function SymError() {
  return true;
}
window.onerror = SymError;

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function popWindow(intWindowID, contentID) {
	switch (intWindowID) {
		case 0:
			// No popup
			break;
		case 1:
			open("popUp_addcomment.cfm?e_id="+contentID,"cWin","width=650,height=550,menubar=yes,personalbar=no,dependent=true,directories=no,status=yes,toolbar=no,scrollbars=yes");
			break;
		case 2:
			open("popUp_contact.cfm","cuWin","width=550,height=250,menubar=no,personalbar=no,dependent=true,directories=no,status=no,toolbar=no,scrollbars=yes");
			break;
		case 3:
			open("popUp_privacy.cfm","pWin","width=550,height=550,menubar=no,personalbar=no,dependent=true,directories=no,status=no,toolbar=no,scrollbars=yes");
			break;
		case 4:
			open("publishEntryedit.cfm?id="+contentID,"eWin","width=600,height=600,menubar=yes,personalbar=no,dependent=true,directories=no,status=yes,toolbar=no,scrollbars=yes");
			break;
		case 5:
			open("popUp_bio.cfm?blog="+contentID,"bWin","width=550,height=550,menubar=no,personalbar=no,dependent=true,directories=no,status=no,toolbar=no,scrollbars=yes");
			break;
		case 6:
			open("popUp_ask.cfm","aWin","width=550,height=550,menubar=no,personalbar=no,dependent=true,directories=no,status=no,toolbar=no,scrollbars=yes");
			break;
		case 7:
			open("popUp_sendStory.cfm?e_id="+contentID,"ssWin","width=550,height=550,menubar=no,personalbar=no,dependent=true,directories=no,status=no,toolbar=no,scrollbars=yes");
			break;
		case 8:
			open("index.cfm?mode=print&e_id="+contentID,"psWin","width=750,height=550,menubar=yes,personalbar=yes,scrollbars=yes");
			break;//,dependent=true,directories=no,status=no,toolbar=no
		case 9:
			open("popUp_login.cfm?ncli=1","lWin","width=650,height=550,menubar=yes,personalbar=no,dependent=true,directories=no,status=yes,toolbar=no,scrollbars=yes");
			break;
		case 11:
			open("popUp_downloadInstructions.cfm","dliWin","width=300,height=200,menubar=no,personalbar=no,dependent=true,directories=no,status=no,toolbar=no,resizable=no,scrollbars=no");
			break;
		case 30:
			open("popUp_gallery.cfm","Gallery","width=800,height=700,menubar=yes,directories=no,status=yes,toolbar=no,scrollbars=yes");
			break;
		case 40:
			open("BestInShow_Enter.cfm?bisc="+contentID,"BestInShow_Enter","width=650,height=550,menubar=yes,directories=no,status=yes,toolbar=no,scrollbars=yes");
			break;
		case 41:
			open("popUp_login.cfm?bisc="+contentID,"lWin","width=650,height=550,menubar=yes,personalbar=no,dependent=true,directories=no,status=yes,toolbar=no,scrollbars=yes");
			break;
		case 42:
			open("BestInShow_ViewEntry.cfm?bisid="+contentID,"BestInShow_Entry","width=650,height=550,menubar=yes,directories=no,status=yes,toolbar=no,scrollbars=yes");
			break;
		case 43:
			open("BestInShow_Vote.cfm?bisc="+contentID,"BestInShow_Vote","width=650,height=550,menubar=yes,directories=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no");
			break;
		default:
			break;
	}
	clean=0;
}

function setClass(objName, clName) {
	var dom = findDOM(objName,0);
	if (dom.className) {
		dom.className = clName;
	}
}
