<!--
function str_replace(search, replace, subject) {
    var f = search, r = replace, s = subject;
    var ra = r instanceof Array, sa = s instanceof Array, f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length;
 
    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = s[i].split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
        }
    };
 
    return sa ? s : s[0];
}

function encode_url(url) {
	return escape(url);
}
function decode_url(url) {
	return unescape(url.replace(/\+/g,  " "));
}

function change(id, newClass) {
	var identity = document.getElementById(id);
	identity.className=newClass;
}

function iframeloc(id, url) {
	var identity = document.getElementById(id);	
	identity.src = url;
}

function wchange(id, newClass) {
	var identity = window.opener.document.getElementById(id);
	identity.className=newClass;
}

function miHoverAction(id, newClass) {
		if (miSelected == id) {
			change(id, newClass);
		} 
}

function miHover(id, newClass) {
	miSelected = id;
	//alert(miSelected);
	setTimeout("miHoverAction('"+id+"', '"+newClass+"');", 500);
}

function miClear(id, newClass) {
	change(id, newClass);
	miSelected = '';
}

function printReport() {
	change('layout', 'disappear');
	change('pReport', 'appear print-report');
	print();
	change('pReport', 'disappear');
	change('layout', 'appear');
}

function checkForQuotesAndLength(what,limit) {
		if (limit != "") {
			if (what.value.length>=limit) {
					return false;
				}
		} 
		// A single quote ' = 34 A double quote " = 39
		if ((event.keyCode == 34) || (event.keyCode == 39)) {
			return false;
		}
		//alert(event.keyCode)
}

function Close_ImgDelWindow(type, blankimg) {
	window.opener.document[type].src = blankimg;
	window.opener.document.MWForm['h'+type].value = '';
	window.close();
}

function updateList(val) {
	var str = window.parent.document.MWForm.lival.value;
	var spos = str.search(val+',');
	if (spos >= 0) { // unticked so remove from str
		str = str_replace(','+val+',',',',str);
	} else { // ticked so add to str
		str += val+',';
	}
	window.parent.document.MWForm.lival.value = str;
} // end function


function imgDel(type, blankimg) {
	document[type].src = blankimg;
	document.MWForm['h'+type].value = '';
	document.MWForm['hT'+type].value = '';
	document.MWForm['hA'+type].value = '';
	change('h'+type+'Add','appear');
	change('h'+type+'Del','disappear');
}

function Close_ImgWindow(id, path, img) {
	window.opener.document[id].src = path+img;

	//window.opener.document.MWForm['h'+id].value = img;
	
	//var theImgFile = 'h' + id;
	window.opener.document.MWForm['h'+id].value = img;
	wchange('h'+id+'Add','disappear');
	wchange('h'+id+'Del','appear');
	window.close();
}

function PopupImgCenterWH(page, width, height, ipathnum) {
	  //var idStr = "&ID="+document.MWForm.ID.value;
	  var top=(screen.height-height)/2;
	  var left=(screen.width-width)/2;
	  window.open(page,"MWPWin","top="+top+",left="+left+",width="+width+",height="+height+","+"menubar=no,scrollbars=no,statusbar=no");
}

/*----------- Mailer Scripts -----------------------------*/

function Close_MailerImgDelWindow(pos) {
	window.opener.document['Img'+pos].src = "../images/mailer/1pxSpacer.gif";
	window.opener.document.MWForm['miImg'+pos].value = '';
	window.close();
}


function Close_MailerImg(pos, miID, img) {
	//window.opener.document.MWForm.pID.value = mmID;
	window.opener.document['Img'+pos].src = "../mailer_images/" + img;
	window.opener.document.MWForm['miImg'+pos].value = miID;
	window.close();
}

function PopupImgLibCenterWH(page, width, height) {
	  var pIDStr = "&pID="+document.MWForm.pID.value;
	  var top=(screen.height-height)/2;
	  var left=(screen.width-width)/2;
	  window.open(page+pIDStr,"MWPWin","top="+top+",left="+left+",width="+width+",height="+height+","+"menubar=no,scrollbars=yes,statusbar=no");
}

function PopupPageCenterWH(page, width, height) {
	  var top=(screen.height-height)/2;
	  var left=(screen.width-width)/2;
	  window.open(page,"MWPWin","top="+top+",left="+left+",width="+width+",height="+height+","+"menubar=no,scrollbars=yes,statusbar=no");
}

function confirm_deleteRVars(id, retID, rVars, tID, pre) {
	if (confirm('Are you sure you want to delete?')) {
		document.location.href = "delete.php?id="+id+"&return="+retID+"&rVars="+rVars+"&tID="+tID+"&pre="+pre;			
	} else {
		return false;
	}
}
/*----------- End Mailer Scripts -------------------------*/

function Close_Refresh()
{
  window.opener.location.reload();
  window.close();
}


function confirm_delete(id, retID, tID, pre) {
	if (confirm('Are you sure you want to delete?')) {
		document.location.href = "delete.php?id="+id+"&return="+retID+"&tID="+tID+"&pre="+pre;			
	} else {
		return false;
	}
}


function make_live($id, $model, $return,$pre) {
	var base_path = '/';
	//alert(base_path+"index.php/fathomit/qstate/"+$id+"/"+$model+"/"+$return+"/"+$pre);
	document.location.href = base_path+"index.php/fathomit/qstate/"+$id+"/"+$model+"/"+$return+"/"+$pre;
}


function make_featured(id, qVal, retID, rVar, tID, pre) {
	var base_path = '/';
	document.location.href = base_path+"index.php/fathomit/make_featured/"+id+"/"+qVal+"/"+tID+"/"+pre+"/"+retID+"/"+rVar+"/index.html";
}


function IsPopupBlocker() {
	var oWin = window.open("","testpopupblocker","width=100,height=50,top=5000,left=5000");
	if (oWin==null || typeof(oWin)=="undefined") {
		return true;
	} else {
		oWin.close();
		return false;
	}
}


function PopupCenterWH(page, width, height) {
	  var top=(screen.height-height)/2;
	  var left=(screen.width-width)/2;
	  window.open(page,"MWPWin","top="+top+",left="+left+",width="+width+",height="+height+","+"menubar=no,scrollbars=no,statusbar=no");
}

function PopupCenterWHS(page, width, height) {
	  var top=(screen.height-height)/2;
	  var left=(screen.width-width)/2;
	  window.open(page,"MWPWin","top="+top+",left="+left+",width="+width+",height="+height+","+"menubar=no,scrollbars=yes,statusbar=no");
}

function PopupImgCenterWHS(page, width, height) {
	  var pIDStr = "&pID="+document.MWForm.pID.value;
	  var top=(screen.height-height)/2;
	  var left=(screen.width-width)/2;
	  window.open(page+pIDStr,"MWPWin","top="+top+",left="+left+",width="+width+",height="+height+","+"menubar=no,scrollbars=yes,statusbar=no");
}
function displayImg(which){
	var mainImg = which.src.replace('/thumb/', '/');
	$('mainImg').src = mainImg;
	var bigImg = which.src.replace('/thumb/', '/large/');
	$('bigIMG').href = bigImg;
}
actDiv = "about";
function showDiv(which){
	$(which).style.display="block";
	$(actDiv).style.display="none";
	actDiv = which;
}

function expand(which){
	elem = $(which);
	if(elem.style.display == "none"){
		$(which).style.display="block";
		$('iIntro').style.display="none";
	}else{
		$(which).style.display="none";
		$('iIntro').style.display="block";
	}
}
function changeText(link,original){
	if(link.innerHTML=="close"){
		link.innerHTML=original;
	}else{
		link.innerHTML="close";
	}
}

theActive = '';
function switchContainer(which,fID,GLat,GLng){
	if(which=="map_canvas"){
		document.getElementById(which).style.display='block';
   		if (GBrowserIsCompatible()) {
        	map = new GMap2(document.getElementById("map_canvas"));
            map.setCenter(new GLatLng(GLat, GLng), 7);
            map.addControl(new GSmallMapControl());
          	map.setMapType(G_SATELLITE_MAP);
          	//map.disableDragging();
        	map.disableDoubleClickZoom();
        	map.disableScrollWheelZoom();
        }
   		document.getElementById("flickrframe").style.display='none';
	} else if(which=='flickrdiv'){
		document.getElementById(which).style.display='block';
		var obj = document.createElement("object");
		obj.data = "http://www.flickr.com/slideShow/index.gne?group_id=&user_id=21879932@N02&set_id="+fID;
		obj.type="text/html";
		obj.id = "flickrObj";
		obj.width = "470px";
		obj.height = "400px";
		document.getElementById(which).appendChild(obj);
		document.getElementById("flickrframe").style.display='block';
	} else {
		document.getElementById(which).style.display='block';
		document.getElementById("flickrframe").style.display='none';
	}
	if (theActive != '') {
		document.getElementById(theActive).style.display='none';
	}
	loimg = which + '-img';
	newImg = document.getElementById(loimg).src;
	document.getElementById(loimg).src = newImg.replace(/-off./i, "-on.");
	if (theActive != '') {
		hiimg = theActive + '-img';
		oldImg = document.getElementById(hiimg).src;
		document.getElementById(hiimg).src = oldImg.replace(/-on./i, "-off.");
	}
	document.getElementById(loimg).parentNode.blur();
	theActive = which;
	return false;
}

//-->