function f_getcookieval(offset){
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) {
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
}

function f_getcookie(name){
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) {
			return f_getcookieval (j);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) {
			break;
		}
	}
	return '';
}

function f_setcookie (name, value, expires){
	document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString()));
}

function test4Cookies(){
	if (test4CookieInt()){
		document.getElementById("cookietest").style.visibility='hidden';
	}
}

function test4CookieInt(){
	f_setcookie("testcook","1",null)
	if (f_getcookie("testcook")=="1"){
		return true;
	}else{
		return false;
	}
}

function clearNew(){
	//clear the 'new' values which are used for page navigation
	//(this protects against problems occuring when the user clicks the
	//browser 'back' button)

	//&newvalues=1 flags the beginning of any 'new' state values that get set for navigation
	//Clear out any existing before setting.

	var i = document.frm.action.indexOf('&newvalues');
	if(i>0){
		document.frm.action = document.frm.action.substr(0,i);
	}
}

function linksearch(module, profile, fieldname, fieldvalue, style, searchdesc){
	//alert(document.frm.action);
	clearNew();
	document.frm.emu_action.value = 'searchrequest';
	//Build the URL-encoded search string
	//KA added work around for Term search (+)/(-).  Might be better taken care of by form variables holding this info??
	if (document.frm.action == 'emuseum.asp'){
		document.frm.action += '?newvalues=1&rawsearch=' + fieldname + '/,/is/,/' + fieldvalue + '/,/false/,/true&newstyle=' + style + '&newprofile=' + profile + '&newsearchdesc=' + searchdesc + '&newcurrentrecord=1&module=' + module + '&row=' + document.frm.row.value; 
		}
	else {
		document.frm.action += '&newvalues=1&rawsearch=' + fieldname + '/,/is/,/' + fieldvalue + '/,/false/,/true&newstyle=' + style + '&newprofile=' + profile + '&newsearchdesc=' + searchdesc + '&newcurrentrecord=1&module='+module;
		}
	//alert(document.frm.action);		
	document.frm.submit();
}

function linksearchW(module, profile, fieldname, fieldvalue, style, searchdesc){
	target = 'http://www.gizapyramids.org/code/emuseum.asp?newvalues=1&rawsearch=' + fieldname + '/,/is/,/' + fieldvalue + '/,/false/,/true&newstyle=' + style + '&newprofile=' + profile + '&newsearchdesc=' + searchdesc + '&newcurrentrecord=1&module=' + module;
	window.open(target, '_blank');
}

function aggregatelink(profile, term, searchdesc, style){
	clearNew();
	//document.frm.emu_action.value = 'searchrequest';
	
	var searchString;
	
	if (window.encodeURIComponent){
	   term = encodeURIComponent(term);
	  }else{
	   term = escape(term);
  	  }
  	  
  	if (window.encodeURIComponent){
	   searchdesc = encodeURIComponent(searchdesc);
	  }else{
	   searchdesc = escape(searchdesc);
  	  }  
			
	if(term == ""){
		searchString = 'ID/,/greater%20than/,/0/,/false/,/false'
		searchdesc = 'All Entries';
	} else {
		searchString = 'FullTextSearch/,/contains/,/' + term + '/,/false/,/true'
	}

	switch (profile){
	case 'Sites':
		url = 'emuseum.asp?newvalues=1&emu_action=advsearch&rawsearch=' + searchString + '&module=Sites&profile=sites&newsearchdesc=' + searchdesc + '&newstyle=' + style + '&aggregatesearch=0';
		break;	
	case 'photos': 
		url = 'emuseum.asp?newvalues=1&emu_action=advsearch&rawsearch=' + searchString +'&module=Photos&profile=photos&newsearchdesc=' + searchdesc + '&newstyle=text&aggregatesearch=0';
		break;	
	case 'plans': 
		url = 'emuseum.asp?newvalues=1&emu_action=advsearch&rawsearch=ClassificationID/,/is/,/6/,/false/,/true/,/' +searchString + '&module=Objects&profile=plans&newsearchdesc=' + searchdesc + '&newstyle=text&aggregatesearch=0';
		break;		
	case 'finds': 
		url = 'emuseum.asp?newvalues=1&emu_action=advsearch&rawsearch=ClassificationID/,/greater than or equal to/,/7/,/false/,/true/,/' + searchString + '&module=Objects&profile=objects&newsearchdesc=' + searchdesc + '&newstyle=text&aggregatesearch=0';
		break;		
	case 'diaries': 
		url = 'emuseum.asp?newvalues=1&emu_action=advsearch&rawsearch=ClassificationID/,/is/,/5/,/false/,/true/,/' + searchString + '&module=Objects&profile=diaries&newsearchdesc=' + searchdesc + '&newstyle=text&aggregatesearch=0';
		break;	
	case 'people': 
		url = 'emuseum.asp?newvalues=1&emu_action=advsearch&rawsearch=' + searchString + '&module=People&profile=people&newsearchdesc=' + searchdesc + '&newstyle=text&aggregatesearch=0';
		break;		
	case 'publisheddocs':
		url = 'emuseum.asp?newvalues=1&emu_action=advsearch&rawsearch=' + searchString.replace(/FullTextSearch/g,'KeyWords') +'&module=PublishedDocs&profile=publisheddocs&newsearchdesc=' + searchdesc + '&newstyle=text&aggregatesearch=0';
		break;
	case 'unpublisheddocs':
		url = 'emuseum.asp?newvalues=1&emu_action=advsearch&rawsearch=' + searchString.replace(/FullTextSearch/g,'KeyWords') +'&module=UnpublishedDocs&profile=unpublisheddocs&newsearchdesc=' + searchdesc + '&newstyle=text&aggregatesearch=0';
		break;
	}

	window.open(url);
	
	//Build the URL-encoded search string
	//document.frm.action = 'emuseum.asp?newvalues=1&quicksearch=' + term + '&module=' + module + '&profile=' + profile + '&newsearchdesc=' + searchdesc + '&newstyle=text&aggregatesearch=0';
	//document.frm.submit();
}

function myresearchlink(profile, val){
	var desc
	desc = document.search.desc.value;
	clearNew();
	if (profile == 'finds') {
		profile = 'objects';
	}
	url = 'http://www.gizapyramids.org/code/emuseum.asp?newvalues=1&emu_action=advsearch&rawsearch=mycollection/,/is/,/' + val + '/,/false/,/false&newprofile=' + profile + '&newsearchdesc=' + desc + '&aggregatesearch=0';
	window.open(url);
}


function singleview(newpage){
	clearNew();
	document.frm.emu_action.value = 'newpage';
	document.frm.action += '&newvalues=1&newstyle=single&newcurrentrecord=' + newpage;
	document.frm.submit();
	
}

function singleviewsite(newpage){
	clearNew();
	document.frm.emu_action.value = 'newpage';
	document.frm.action += '&newvalues=1&newstyle=single&newcurrentrecord=' + newpage; //+ '&searchdesc=' + searchdesc;
	document.frm.submit();
}

function submitpage(action,para){
	clearNew();
	document.frm.emu_action.value = action;
	var cS;
	if (document.frm.action.indexOf("?")==-1){cS='?'}else{cS='&'}
	switch (action){
	case 'newpage' :
		document.frm.action += cS + 'newvalues=1&newcurrentrecord=' + para;
		break
	case 'style' :
		document.frm.action += cS + 'newvalues=1&newstyle=' + para;
		break
	case 'sort' :
		document.frm.action += cS + 'newvalues=1&newcurrentrecord=1&newsortstring=' + para;
		break;
	case 'page' :
		document.frm.emu_action.value = 'newpage';
		document.frm.action += cS + 'newvalues=1&newpage=' + para;
		break;
	case 'profile' :
		document.frm.action += cS + 'newvalues=1&newprofile=' + para;
		break
	default :
		break
	}
	document.frm.submit();
	}

	
function switchprofile(profile){
		clearNew();
		var cS;
		if (document.frm.action.indexOf("?")==-1){cS='?'}else{cS='&'}
		//alert(document.frm.action);
		document.frm.action += cS + 'newvalues=1&newprofile=' + profile;
		document.frm.submit();
	}
	
function switchlang(lang){
	var cS;
		
	var loc=document.location.href;
		
	if (loc.indexOf("?")==-1){cS='?'}else{cS='&'}
	
	var i = loc.indexOf("&lang=");
	if(i==-1){
		i = loc.indexOf("?lang=");
	}
	
	
	if (i>0){
		var j = loc.indexOf("=",i+1);
		if (j==-1){
			loc = loc.substr(0,i);
		}else{
			var k = loc.indexOf("&",j+1);
			if (k==-1){
				loc = loc.substr(0,j+1)+ lang;
			}else{
				loc = loc.substr(0,j+1)+ lang + loc.substr(k);
			}
		}
			
	}else{
		loc+=cS+'lang=' + lang;
	}
	
	
	var i = loc.indexOf("&profile=");
	if(i==-1){
		i = loc.indexOf("?profile=");
	}

	if (i>0){
		var j = loc.indexOf("&",i+1);
		if (j==-1){
			loc = loc.substr(0,i);
		}else{
			loc = loc.substr(0,i)+loc.substr(j);
		}

	}

	if (loc.indexOf("?")==-1){cS='?'}else{cS='&'}
	loc+=cS+'profile=';
	var i = loc.indexOf("&newprofile=");
	if(i==-1){
		i = loc.indexOf("?newprofile=");
	}

	if (i>0){
		var j = loc.indexOf("&",i+1);
		if (j==-1){
			loc = loc.substr(0,i);
		}else{
			loc = loc.substr(0,i)+loc.substr(j);
		}

	}

	if (loc.indexOf("?")==-1){cS='?'}else{cS='&'}
	loc+=cS+'newprofile=';
	document.langswop.sessionid.value=document.frm.sessionid.value;
	document.langswop.searchxml.value=document.frm.searchxml.value;
	document.langswop.action=loc;
	document.langswop.submit();
}

function submitcollection(colname,colid){
	clearNew();
	document.frm.emu_action.value = 'collection'
	document.frm.action = 'emuseum.asp?emu_action=collection&collection=' + colid + '&collectionname=' + encodeURI(colname) + '&currentrecord=1&moduleid=4&module=Sites';
	document.frm.module.value= 'sites';
	document.frm.profile.value= 'sites';
	document.frm.submit();
}

function activatemycollection(colname,colid){
	clearNew();
	var sourcef = document.getElementById("frm");
	sourcef.emu_action.value = 'mycollectionactivate'
	if (window.encodeURIComponent){
		sourcef.action = 'emuseum.asp?emu_action=mycollectionactivate&mycollection=' + colid + '&mycollectionname=' + encodeURIComponent(colname) + '&currentrecord=1';
	}else{
		sourcef.action = 'emuseum.asp?emu_action=mycollectionactivate&mycollection=' + colid + '&mycollectionname=' + escape(colname) + '&currentrecord=1';
	}
  	sourcef.submit();
  	//window.history.back(-1);
}


function addobjects2mycoll(byuser){
	var oidtext='';
	var oids='';
	var otexts='';
	var surl='';
	var objids='';
	
	var sourceuc = document.getElementById("usercoll");
	var sources4 = document.getElementById("selected4mycoll");
	
	//alert(sourceuc);
	//alert(sources4);
	
	if (sourceuc!=null){
		
		var pagesize=sourceuc.pagesize.value;
		var colid=sourceuc.currentusercollid.value;
		var colname=sourceuc.currentusercollid[sourceuc.currentusercollid.selectedIndex].text;
		var modid=sourceuc.moduleid.value;
		var lang=sourceuc.lang.value;
		var cachedIDs=f_getcookie("cachedmycollitems");
		var cachedTexts=f_getcookie("cachedmycollitemstext");
		var aCachedIDs=new Array();
		var aCachedTexts=new Array();
		if (cachedIDs.length>0){
			aCachedIDs=cachedIDs.split(",");
			aCachedTexts=cachedTexts.split("/,/");
		}
		if (colid=='' && byuser=='1'){
			alert("Please select a my Collection from the drop down list.");
		}else{
			for (var i=0;i<sources4.elements.length;i++) {
				if (sources4.elements[i].name=='add2mycoll'){
					oidtext=sources4.elements[i].value;
					var j = oidtext.indexOf(":::",0);
					var oid = 0;
					var otext = "";
					if (j>-1){
						oid = oidtext.substring(0,j);
						otext = oidtext.substring(j+3);
					}
					if (oid!=0){
						if(sources4.elements[i].checked==1){
							if (!isInCachedMyColls(aCachedIDs,modid,oid)){
								aCachedIDs.push(modid+'^'+oid);
								aCachedTexts.push(otext);
							}
							if (byuser=='1'){
								sources4.elements[i].checked=0;
							}
						}else{
							//need to remove it
							for (var k=0;k<aCachedIDs.length;k++){
								var singleCached=aCachedIDs[k];
								var l=singleCached.indexOf("^",0);
								if (l>-1){
									var smodid=singleCached.substring(0,l);
									var soid=singleCached.substring(l+1);
									if (modid==smodid && soid==oid){
										aCachedIDs.splice(k,1);
										aCachedTexts.splice(k,1);
									}
								}
							}
						}
					}
				}
			}
			oids=aCachedIDs.join(",");
			otexts=aCachedTexts.join("/,/");
			if (byuser=='1'){
				if (oids.length>0){
					var profile = document.getElementById("profile").value;
					//profile = profile.replace(/_!_/g," and ");
					//alert(profile);
					if (window.encodeURIComponent){
						surl='AddObjToColl.asp?byuser=1&lang='+lang+'&objectid=' + oids + '&mycollectionid=' + colid + '&objtext=' + encodeURIComponent(otexts)+'&mycollectionname='+encodeURIComponent(colname)+'&profile=' + encodeURIComponent(profile);	
						//alert(surl);
					}else{
						surl='AddObjToColl.asp?byuser=1&lang='+lang+'&objectid=' + oids + '&mycollectionid=' + colid + '&objtext=' + escape(otexts)+'&mycollectionname='+escape(colname)+'&profile=' + encodeURIComponent(profile);	
					}

					openWindow(surl,'Confirmation','width=400,height=300,scrollbars=yes,resizable=no,screenx=200,screeny=200,left=200,top=200,titlebar=0');
					f_setcookie("cachedmycollitems","",null); 
					f_setcookie("cachedmycollitemstext","",null); 
				}
			}else{
				if (oids.length>0){
					f_setcookie("cachedmycollitems",oids,null); 
					f_setcookie("cachedmycollitemstext",otexts,null); 
				}
			}
		}
	}
}


function checkForSelectedMyColls(){
	addobjects2mycoll(0);
}

function checkCachedMyColls(){
	var sources4 = document.getElementById("selected4mycoll");
	if (document.getElementById("usercoll")!=null){
		var modid=document.getElementById("usercoll").moduleid.value;
		aCachedIDs=f_getcookie("cachedmycollitems").split(",");
	
		for (var i=0;i<sources4.elements.length;i++) {
			var current=sources4.elements[i].value;
			var j = current.indexOf(":::",0);
			if (j>-1){
				var oid=current.substring(0,j);
				if (isInCachedMyColls(aCachedIDs,modid,oid)){
					sources4.elements[i].checked=1;
				}
			}

		}
	}
}

function isInCachedMyColls(aCachedIDs,modid,oid){
	var to_return=false;
	for (var k=0;k<aCachedIDs.length;k++){
		var singleCached=aCachedIDs[k];
		var l=singleCached.indexOf("^",0);
		if (l>-1){
			var smodid=singleCached.substring(0,l);
			var soid=singleCached.substring(l+1);
			if (modid==smodid && soid==oid){
				to_return= true;
			}
		}
	}
	return to_return;
}

function openWindow(winURL,winName,winFlags){
    var myWindow=window.open(winURL,winName,winFlags);
    myWindow.focus();
}

function showReport(reportname){
	document.report.action = 'eMuseum.asp?emu_action=report&report=' + reportname + '&sessionid=' + document.frm.sessionid.value;
	//openWindow('','reportPopup','width=800,height=600,scrollbars=yes,resizable=yes');
	//document.report.submit(); as it submitted twice!
}

function changepage(page,profile){
	clearNew();
	document.frm.emu_action.value = 'newpage';

	if(document.frm.action.indexOf('?') > 0){
		document.frm.action += '&';
	}else{
		document.frm.action += '?';
	}
	document.frm.action += 'newvalues=1&newpage=' + page + '&newprofile=' + profile;
	document.frm.submit();
}

function setMedia2(filename,caption,title,lang){
	//selects a particular media record for enlarging
	document.media.filename.value = filename;
	document.media.caption.value = caption;
	document.media.title.value = title;
	//window.open('http://demo.emuseum.com/giza/code/emuseum.asp?newpage=media_enlarged','_blank','600','600');
	spawn_scroll('../html/media_enlarged2_' + lang + '.html','_blank','700','600');
	}

function setMedia(filename,caption,title,lang){
	document.media.filename.value = filename;
	document.media.caption.value = caption;
	document.media.title.value = title;
	spawn('../html/media_enlarged_' + lang + '.html','_blank','600','600');
}


function setQTVR(filename){
	document.media.filename.value = filename;
	//spawn(filename,'_blank','600','600');
	spawn('../html/media_enlarged3_EN.html','_blank','800','500');
}

function setMedia_QTVR(filename, rend, desc, subj, other, date, problems, person, remarks, contact){
	document.media.filename.value = filename;
	document.media.renditionnumber.value = rend;
	document.media.description.value = desc;
	document.media.subjects.value = subj
	document.media.otherphotonum.value = other;
	document.media.date.value = date;
	document.media.problems.value = problems;
	document.media.person.value = person;
	document.media.remarks.value = remarks;
	if (contact != undefined){
		document.media.contact.value = contact;
		}
	else {
		document.media.contact.value = '';
	}	
	//spawn(filename,'_blank','600','600');
	spawn('../html/media_enlarged3_EN.html','_blank','800','500');
}



function setMedia_Photos(filename,rend,desc,subj,other,date,problems,person,remarks,contact,imagepub){
	//selects a particular photo record for enlarging
	document.media.filename.value = filename;
	document.media.renditionnumber.value = rend;
	document.media.description.value = desc;
	document.media.subjects.value = subj
	document.media.otherphotonum.value = other;
	document.media.date.value = date;
	document.media.problems.value = problems;
	document.media.person.value = person;
	document.media.remarks.value = remarks;
	document.media.imagepub.value = imagepub;
	if (contact != undefined){
		document.media.contact.value = contact;
		}
	else {
		document.media.contact.value = '';
	}
	//window.open('http://demo.emuseum.com/giza/code/emuseum.asp?newpage=media_enlarged2','_blank','700','600');
	spawn_scroll('../html/media_enlarged2_EN.html','_blank','700','600');
}

function setPDF(filename){
	var fn = filename //document.media.file.value;
	//fn = fn.replace(/\/d:\\full\\/gi,'/pdf%20library/');
	window.open(fn,'_blank');
}

function spawn(url, nameW, w, h){
  	if (navigator.appVersion.indexOf('4') != -1) {
		// Vars for centering the new window on Version 4 Browsers
		x4 = screen.width/2 - (w/2);
		y4 = screen.height/2 - (h/2);
		window.open(url, nameW, 'height='+h+',width='+w+',scrollbars=0,resizable=0,menubar=0,toolbar=0,status=0,location=0,directories=0,left=' + x4 + ',top=' + y4 + '');
  	}else{
    	window.open(url, nameW, 'height='+h+',width='+w+',scrollbars=0,resizable=1,menubar=0,toolbar=0,status=0,location=0,directories=0,left=150,top=200');
	}
}

function spawn_scroll(url, nameW, w, h){
  	if (navigator.appVersion.indexOf('4') != -1) {
		// Vars for centering the new window on Version 4 Browsers
		x4 = screen.width/2 - (w/2);
		y4 = screen.height/2 - (h/2);
		window.open(url, nameW, 'height='+h+',width='+w+',scrollbars=1,resizable=0,menubar=0,toolbar=0,status=0,location=0,directories=0,left=' + x4 + ',top=' + y4 + '');
  	}else{
    	window.open(url, nameW, 'height='+h+',width='+w+',scrollbars=1,resizable=1,menubar=0,toolbar=0,status=0,location=0,directories=0,left=150,top=200');
	}
}

function openImage(imgName,sTitle,sCaption){
	var sHTML = "&lt;html&gt;&lt;head&gt;&lt;title&gt;"+sTitle+"&lt;/title&gt;&lt;link rel='stylesheet' href='../txtStyle.css' type='text/css'/&gt;&lt;/head&gt;&lt;body&gt;&lt;table cellpadding='0' cellspacing='0' border='0' width='100%'&gt;&lt;tr valign='top'&gt;&lt;td class='title'&gt;"+sTitle+"&lt;/td&gt;&lt;td align='right' class='txt'&gt;&lt;a href='javascript:window.close();'&gt;Close&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='txt'&gt;"+sCaption+"&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br&gt;&lt;img src='getimage.asp?filename="+imgName+"&type=full' width='400' height='400' border='0' alt='"+sTitle+"'&gt;&lt;/body&gt;&lt;/html&gt;";
	var theWindow = "";
	theWindow = window.open("","","height=540,width=540,resizable,scrollbars");
	if(theWindow){
    	theWindow.document.write(sHTML);
    	theWindow.document.close();
  	}
}


function checkold() {
	if (window.document.readyState=='complete'){
	   window.open("http://www.gizapyramids.org","_self","","");
	} else {
           window.setTimeout('check();',500000);		
        }
}

var secs
var timerID = null
var timerRunning = false
var delay = 1000

function check()
{
    // Set the length of the timer, in seconds
    secs = 7
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        window.open("http://www.gizapyramids.org","_self","","");
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}

function appendOrReplace2Url(sUrl,sKey,sValue){
 sUrl=removeFromUrl(sUrl,sKey);
 if (sValue.length>0){
  var cS;
  if (sUrl.indexOf('?')==-1){
   cS='?';
  }else{
   cS='&';
  }
  if (window.encodeURIComponent){
   return sUrl+cS+sKey+'='+encodeURIComponent(sValue);
  }else{
   return sUrl+cS+sKey+'='+escape(sValue);
  }
 }else{
  return sUrl;
 }
}

function removeFromUrl(sUrl,sKey){
	var i = sUrl.indexOf('?'+sKey+'=');
	if (i==-1){
		i = sUrl.indexOf('&'+sKey+'=');
	}
	if (i>-1){
		var j=sUrl.indexOf('&',i+1);
		if (j==-1){
			return sUrl.substr(0,i);
		}else{
			return sUrl.substr(0,i+1) + sUrl.substr(j+1);
		}
	}else{
		return sUrl;
	}
}

function termSearch(cn,term,termid)
{
	clearNew();

	document.frm.action += "&newvalues=1&newstyle=text&rawsearch=TermCN/,/begins with/,/"+cn+"/,/false/,/true&newaction=searchrequest&newsearchdesc=" + term;
	document.frm.submit();
}

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 popup() {
	//if (IsPopupBlocker()) {
		document.getElementById("message").style.display='block';
		document.getElementById("message").style.visibility='visible';
	//} 
	//else {
	//	window.open('http://www.gizapyramids.org/html/survey.html','Survey','width=505,height=720');
	//}
}

function test() {
  var sName = 'GizaSurvey';
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }
  // a cookie with the requested name does not exist
  return null;
}

function decline(){
  date = new Date();
  document.cookie = 'GizaSurvey=Declined=True; expires=; path=/'
  window.location = 'http://www.gizapyramids.org/';
}

function setAggResultsTable(){
	var table = document.getElementById("agg");
	var cells = table.getElementsByTagName("td"); 
	for (var i = 0; i < cells.length; i++) { 
		if(cells[i].innerHTML == ""){
			cells[i].innerHTML = "&nbsp;";
		}			
	}
}

function returnMyColl(id,collname){
	var url
	url = 'http://www.gizapyramids.org/code/emuseum.asp?newvalues=1&emu_action=advsearch&rawsearch=mycollection/,/is/,/' + id + '/,/false/,/true&newsearchdesc=' + collname + '&newstyle=mycoll&newprofile=profilesearch&mycollid=' + id + '&aggregatesearch=1&aggregateby=displayprofile';
	window.open(url);
}