/*
Designed by <theFactor.e>
http://www.tfe.nl

CVS Header Information:  
    $Source: f:/tfecvs/cvs/Apenheul/website/htdocs/js/default.js,v $
    $Revision: 1.15 $
    $Date: 2006/05/18 10:18:45 $
    $Name:  $
    $Author: kleinebeer#wouter $
*/
// Foto popup
function popupFoto(img,txt){
	foto1= new Image();
	foto1.src=(img);
	CheckFoto(img,txt);
}
function CheckFoto(img,txt){
	if((foto1.width!=0)&&(foto1.height!=0)){
		viewFoto(img,txt);
	}
	else{
		uitvoering="CheckFoto('"+img+"','"+txt+"')";
		interval=setTimeout(uitvoering,20);
	}
}
function viewFoto(img,txt){
	imgbreedte=foto1.width;
	imghoogte=foto1.height;
	if (!txt) {txt=img}
	vars="width="+imgbreedte+",height="+imghoogte+",left="+((screen.width-imgbreedte)/2)+",top="+((screen.height-imghoogte)/2);
	newwindow=window.open("","nieuwvenster",vars);
	newwindow.document.clear();
	newwindow.document.write("<html>\n<head>\n<title>"+txt+"</title>\n");
	newwindow.document.write("<meta http-equiv=\"imagetoolbar\" content=\"no\">\n");
	newwindow.document.write("</head>\n\n<body style=\"margin:0px; padding:0px;\" onBlur=\"window.close()\">\n"); 
	newwindow.document.write("<img src=\""+img+"\" border=\"0\" onclick=\"javascript:window.close()\">\n"); 
	newwindow.document.write("</body>\n</html>\n"); 
	if (newwindow.document.focus) {newwindow.document.focus();}
	newwindow.document.close(); 
}

// Layer switch
var isIE = (navigator.appName.toLowerCase().indexOf("microsoft") != -1);

function setFlashMenuTop(){
	
	document.getElementById('mainFlashMenu').style.zIndex = "300";
	
	if (!isIE) {
		
		document.getElementById('mainContent').style.overflow = "hidden";
	}
	
	var obj = new Object()
	obj.visible="visible";
	thisMovie("navigatie").sendNavigationExpand();
	return obj;
}
function setFlashMenuBottom(){
	
	document.getElementById('mainFlashMenu').style.zIndex = "10";
	
	if (!isIE) {
		document.getElementById('mainContent').style.overflow = "auto";
	}
	var obj = new Object()
	obj.visible="hidden";
	return obj;
}

// Show hide content
function showHtml() {
	document.getElementById('mainContent').style.display = "block";
}
function hideHtml(){
	document.getElementById('mainContent').style.display = "none";
}

// Ajax Stuff
function getContentPidNumb(pid) {
	o = new Object();
	o.pid = pid;
	sendNavigationAction(o);
}

function getContentPid(o) {
	var pid = o.PAGEID;
	var searchTerm = o.searchTerm;
	if(searchTerm){
		execContentUrl('htmlcontent.cfm?pid=' + pid + "&keywords="+ searchTerm);
	} else{
		execContentUrl('htmlcontent.cfm?pid=' + pid);
	}
}

function execContentUrl(url) {
	var target = 'ajaxcontent';
	var ajaxReady = false;
	new Rico.Effect.Size( 'mainContent', null, 1, 200, 4, {
		complete:function() {
			target.innerHTML = "";
			var myAjax = new Ajax.Updater(target, url, {
				method: 'get', parameters: '',onComplete: function() {
					new Rico.Effect.Size( 'mainContent', null, 430, 200, 4, {
						complete:function() {
							//nix
						}
					});
				}
			});
		}
	} );
	pageTracker._trackPageview(cleanUpUrl(url));
}

function getContentUrl(url) {
	// get pid uit url
	var pid = "";
	var itemid = "";
	var contentitemid = "";
	if ( url.indexOf("?") > -1 )
	{
	  var strQueryString = url.substr(url.indexOf("?")).toLowerCase();
	  var aQueryString = strQueryString.split("&");
	  for ( var iParam = 0; iParam < aQueryString.length; iParam++ )
	  {
	    if (aQueryString[iParam].indexOf("pid=") > -1 )
	    {
	      var aParam = aQueryString[iParam].split("=");
	      pid = aParam[1];
	    }
	    else if (aQueryString[iParam].indexOf("contentitemid=") > -1 )
	    {
	      var aParam = aQueryString[iParam].split("=");
	      contentitemid = aParam[1];
	    }
	    else if (aQueryString[iParam].indexOf("itemid=") > -1 )
	    {
	      var aParam = aQueryString[iParam].split("=");
	      itemid = aParam[1];
	    }
	  }
	}
	o = new Object();
	o.pid = pid;
	o.itemid = itemid;
	o.contentitemid = contentitemid;
	o.url = url;
	sendNavigationAction(o);
	pageTracker._trackPageview(cleanUpUrl(url));
}


/*
function getContentPid(o) {
	alert(typeof o);
	if (typeof o == 'object') {
		var pid = o.PAGEID;
		var searchTerm = o.searchTerm;
		if(searchTerm){
			getContentUrl('htmlcontent.cfm?pid=' + pid + "&keywords="+ searchTerm);
		} else{
			getContentUrl('htmlcontent.cfm?pid=' + pid);
		}
	} else if (typeof o == 'number') {
		obj = new Object();
		obj.PAGEID = o;
		getContentPid(obj);
	}
}
*/

function popupContentPid(pid) {
	var popup;
	popup=window.open('index.cfm?pid='+pid, 'popupContent', 'width=800,height=600,scrollbars=yes,location=no');
	popup.focus();
}

// Flash functies
function thisMovie(movieName) {
	
    if (isIE) {
        return window[movieName];
    }
    else {
        return document[movieName];
    }
}	

function sendNavigationAction(o) {
	try {
		thisMovie("Apenheul").sendNavigationAction(o);
	} catch(err) {
		//No movie
	}
}

function cleanUpUrl(url) {
	url = url.replace("http://www.apenheul.nl/", "/");
	url = url.replace("http://www2.apenheul.nl/", "/");
	url = url.replace("http://www.apenheul.de/", "/");
	url = url.replace("http://www.apenheul.com/", "/");
	if (url.substr(0, 1) != "/") {
		url = "/" + url;
	}
	return url;
}