﻿function jsRequest(request) {
    var queryString = location.search.substring(1);
    var startPos = queryString.indexOf(request + "=");
    if (startPos > -1) {
        startPos = startPos + request.length + 1;
        var endPos = queryString.indexOf("&",startPos);
        if (endPos == -1)
            endPos = queryString.length;
        return unescape(queryString.substring(startPos,endPos));
    }
    return "";
}
function getImgSize(imgSrc, att){
	var newImg = new Image();
	newImg.src = imgSrc;
	var height = newImg.height;
	var width = newImg.width;
	
	return eval(att); 
}
function hoverImageFor(source){
	var fileName	= source.src
	var genderPos 	= fileName.indexOf("_mo") + 1
	var gender 		= fileName.substring(genderPos, fileName.length-4)
	var fileBase	= fileName.substring(0, genderPos-1)

	switch (gender){
		case "mou":
			var fileName = fileName.replace("_mou", "_mov"); 
		break;
		case "mov":
			var fileName = fileName.replace("_mov", "_mou");
		break;
		default:
			var fileName = fileName ;
	}
	
	source.src = fileName
}
function fnOpenWin(url, width, height, showScroll){
    if(!showScroll) 
	    showScroll = 'no' 
    else 
	    showScroll = 'yes'
    window.open(url,"_blank", "height="+height+",width="+width+",top=0,status=no,resizable=yes,toolbar=no,menubar=no,location=no,scrollbars="+showScroll);
}
function profileLink(doChange){

        var strMode;
        if (doChange) {
            // edit profile
            strMode = "change";
        } else {
            // create new profile
            strMode = "create";
        }

        try{
            location.href = "profiel/?mode=" + strMode + "&email=" + document.getElementById("ctl00_ContentPlaceHolder1_tbEmail").value;
        }
        catch (e){
            location.href = "profiel/?mode=" + strMode + "email=" + document.getElementById("ctl00$ctl00$ContentPlaceHolder1$leftMenus$tbEmail").value;
        }
}
function checkActive(setThisPage) {

	var a = document.getElementsByTagName("a");
	if (window.location.href.substr(location.href.length - 1, 1) == '/') {
		var loc = window.location.href + ''; 
	}
	else {
		var loc = window.location.href;
	}
	
	if(setThisPage.length > 0){
		loc = setThisPage
    }
    else{
		loc = loc
	}
	
	for(var i=0; i < a.length; i++) {
		if (a[i].href == loc) {
			a[i].setAttribute("class", "active");
			a[i].setAttribute("className", "active");
		}
	}
}
function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
	elm.addEventListener(evType, fn, useCapture);
	return true;
	} else if (elm.attachEvent) {
	var r = elm.attachEvent('on' + evType, fn);
	return r;
	} else {
	elm['on' + evType] = fn;
	}
}
function hoverModule(source){
	var moduleId	= source.id
	var genderPos 	= moduleId.indexOf("_mo") + 1
	var gender 		= moduleId.substring(genderPos, moduleId.length)
	var moduleName 	= moduleId.substring(0, genderPos-1)
	var hideItem    = moduleId
	
	switch (gender){
		case "mou":
			showItem    = moduleId.replace("_mou", "_mov")
		break;
		case "mov":
			showItem    = moduleId.replace("_mov", "_mou")
		break;
	}
	
	document.getElementById(hideItem).style.display = "none";
	//document.getElementById(hideItem).onmouseover = "";
	//addEvent(document.getElementById(showItem), 'onmouseover', function() { alert('test') }, false); 
	document.getElementById(showItem).style.display = "block";
}

function ModuleHover(moduleId, imgId, contentId) {
    document.getElementById(moduleId).onmouseover = function() {
        document.getElementById(imgId).style.display = "none";
        document.getElementById(contentId).style.display = "block";
    }
    document.getElementById(moduleId).onmouseout = function() {
        document.getElementById(imgId).style.display = "block";
        document.getElementById(contentId).style.display = "none";
    }

}
function getFilename() 
{ 
    url = a.href; 
    x = url.length; 
    while((url.substring(x,x-1))!= "/"){ x--; } clipstart = x; 
    return url.substring(url.length,clipstart); 
} 
function fnVoid(){}

//this function handles the textbox changeovers
function handleTextBoxClick(el, defaultValue) {
    var txt = document.getElementById(el).value;
    if (txt == defaultValue) {
        document.getElementById(el).value = "";
        document.getElementById(el).className = "";
    }
}

//handles onblur event
function handleTextBoxBlur(el, defaultValue) {
    var txt = document.getElementById(el).value;
    if (txt == "") {
        document.getElementById(el).value = defaultValue;
        document.getElementById(el).className = "watermark"
    }
}

addEvent(window, 'load', checkActive, false);

// counter     
var i = 0;
// create object     
imageObj = new Image();
// set image list
images = new Array();
images[0] = "/img/menu/background_mov.png"
images[1] = "/img/menu/background_mou.png"
images[2] = "/img/home/leftbanner_top.jpg"
images[3] = "/img/home/leftbanner_middle.jpg"
images[4] = "/img/home/leftbanner_bottom.jpg"
images[5] = "/img/home/newsbanner_top.jpg"
images[6] = "/img/home/newsbanner_bottom.jpg"
images[7] = "/img/home/rightbanner_top.jpg"
images[8] = "/img/home/rightbanner_middle.jpg"
images[9] = "/img/home/rightbanner_bottom.jpg"
images[10] = "/img/home/posterscroller_top.jpg"
images[11] = "/img/home/posterscroller_middle.jpg"
images[12] = "/img/home/posterscroller_bottom.jpg"
images[13] = "/img/home/smallbannergrey_top.jpg"
images[14] = "/img/home/smallbanner_middle.jpg"
images[15] = "/img/home/smallbanner_bottom.jpg"
images[16] = "/img/home/middlebanner_top.jpg"
images[17] = "/img/home/middlebanner_middle.jpg"
images[18] = "/img/home/middlebanner_bottom.jpg"

// start preloading
for (i = 0; i <= 17; i++) {
    imageObj.src = images[i];
}
function Toggle(el, anchor) {
    if (document.getElementById(el).style.display == "none") {
        document.getElementById(el).style.display = "block";
        if(anchor.length > 0) location.href = "#" + anchor;
        //document.getElementById("divFiller").style.display = "none";
    } else {
        document.getElementById(el).style.display = "none";
        //document.getElementById("divFiller").style.display = "block";
    }
    return false;
}
function getMovieRootPath(window) {
    pathArray = window.location.pathname.split('/');
    var movieRoothPath
    movieRoothPath = pathArray[1].toString() + "/" + pathArray[2].toString()
    return movieRoothPath
}
function openPage(useScreen, page, closeCurrent) {
    var baseUrl
    var gotoUrl
    baseUrl = getMovieRootPath(useScreen)
    gotoUrl = "/" + baseUrl + page
    useScreen.location.href = gotoUrl
    if(closeCurrent) self.close()
}
