var expDate;
var language;
var taal;
var deeplink = 'no'; //default waarden wordt in flash gebruikt

var itemArray = ['', 'beginpagina','activiteiten','bezienswaardig','horeca','natuur/','overnachten','plaatsen','verhuur','instellingen','service/index','contact','links'];

var provArray = ['','drenthe','flevoland','friesland','gelderland','groningen','limburg','noordbrabant','noordholland','overijssel','utrecht','zeeland','zuidholland'];
var provArraySpelling = ['','Drenthe','Flevoland','Friesland','Gelderland','Groningen','Limburg','Noord-Brabant','Noord-Holland','Overijssel','Utrecht','Zeeland','Zuid-Holland'];

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_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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function dropdownmenu() {
taal = document.form_dropdownmenu.taal.value;
doel = document.form_dropdownmenu.menu.options[document.form_dropdownmenu.menu.selectedIndex].value;
if (doel != 'noselect') {
parent.content.location.href = '../' + doel + '.html';
}
}

function writeDropdownProvincie() {
temp = document.location.href;
provActief = GetCookie();
provActief = provActief.split('&');
provActief = provActief [2];
provActief = provActief.split('=');
provActief = provActief[1];

if (temp.indexOf('/ned/') > 0) {
	document.write('<span class="blauw">andere provincie:</span>');
}
else if (temp.indexOf('/eng/') > 0) {
	document.write('<span class="blauw">select another province:</span>');
}
else {
	document.write('<span class="blauw">w&auml;hlen Sie eine Provinz:</span>');
}

document.write('<select name="menu" onchange="dropdownProvincie()">');
  for (i=1; i<provArray.length ; i++) {
	if (provActief != provArray[i]) {
		document.write('<option value="' + provArray[i] + '">' + provArraySpelling[i] + '</option>');
	}
	else {
		document.write('<option value="' + provArray[i] + '" selected>' + provArraySpelling[i] + '</option>');
}
}
document.write('</select>');

}


function dropdownProvincie() {
provincie = document.form_dropdownmenu.menu.options[document.form_dropdownmenu.menu.selectedIndex].value;
top.document.location.href = '../../../index.html?provincie=' + provincie;
}

function playvideo() {
/*connectie = getConnectie();
parent.flashmov.location.replace('flash/openmovie.html?taal=' + taal + '&deeplink=' + doel + '&connectie=' + connectie);
*/
}

function setCookie(taal,connectie,provincie) {
path= '/';
getExpDate();
varcookie = 'taal=' + taal + '&connectie=' + connectie + '&provincie=' + provincie;
document.cookie = 'hollandinvideo_01' + "=" + escape(varcookie) +
 ((expDate == null) ? "" : ("; expires=" +
expDate.toGMTString())) +
((path) ? ";path=" + path : "");
}

function getExpDate() {
	expDate = new Date();
	expDate.setDate(expDate.getDate() + parseInt(365));
	expDate.toGMTString();
}

function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie() {
        var arg = 'hollandinvideo_01' + "=";
        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 getCookieVal (j);
                i = document.cookie.indexOf(" ", i) + 1;
                        if (i == 0)
                                break;
                }
   return null;
}

function taal(keuze) {
language = keuze;
MM_showHideLayers('taal','','hide');
taal = keuze;
laag = 'connectie_' + keuze;
MM_showHideLayers(laag,'','show');
}

function connectie(keuze) {
connectie = keuze;
MM_showHideLayers('ned_map_a','','hide');
MM_showHideLayers('ned_map_b','','show');
MM_showHideLayers(laag,'','hide');
if(deeplink == 'no') {
laag = 'go_' + taal;
MM_showHideLayers(laag,'','show');
}
else {
ga_verder(provincie);
}
}


function ga_verder_intro(formulier) {
switch (formulier) {
	case 'form_ned':
	provincie = document.form_ned.menu.options[document.form_ned.menu.selectedIndex].value;
	break;
	case 'form_eng':
	provincie = document.form_eng.menu.options[document.form_eng.menu.selectedIndex].value;
	break;
	case 'form_dui':
	provincie = document.form_dui.menu.options[document.form_dui.menu.selectedIndex].value;
	break;
}
setCookie(taal,connectie,provincie);
koekie = GetCookie();
parent.content.location.href = 'prov_' + provincie + '/html/' + taal + '/beginpagina.html';
parent.flashmov.location.href = 'flash/openmovie.html?taal=' + taal + '&deeplink=' + deeplink + '&connectie=' + connectie + '&provincie=' + provincie;
}

function ga_verder(provincie) {
setCookie(taal,connectie,provincie);
koekie = GetCookie();
parent.content.location.href = 'prov_' + provincie + '/html/' + taal + '/beginpagina.html';
parent.flashmov.location.href = 'flash/openmovie.html?taal=' + taal + '&deeplink=' + deeplink + '&connectie=' + connectie + '&provincie=' + provincie;
}

function cookiecheck() {
deeplinkcheck();
if (GetCookie()) {
getValues();
}
else {
//parent.content.MM_showHideLayers('fotos','','show');
}

}

function loadcheck() {

if (window != top && top.location.href.indexOf('lajos')<0) { 
top.location.href = location.href;
}
else if (document.location.href == 'http://hollandinvideo.nl/' || document.location.href == 'http://hollandinvideo.nl/index.html') {
top.location.href = 'http://www.hollandinvideo.nl';
}
//alert('site wordt nu aangepast, het kan dat onderdelen tijdelijk niet goed werken');
}

function init_content() {
if (window == top) { 
top.location.href = 'http://www.hollandinvideo.nl';
}
tmp = document.location.href;
for (i=0; i<itemArray.length; i++) {
		if (tmp.indexOf(itemArray[i])>0)
		{
		showitem= 'menu_' + i;
		document.getElementById(showitem).style.color = "#E94141";
		}
}
}

function directlink(id,provincie) {
items = parent.flashmov.location.href;
items = items.split('?');
items = items[1].split('&');
taal = items[0].split('=');
taal = taal[1];
connectie = items[2].split('=');
connectie = connectie[1];
deeplink = id;


parent.flashmov.location.href = 'http://www.hollandinvideo.nl/flash/openmovie.html?taal=' + taal + '&deeplink=' + deeplink + '&connectie=' + connectie + '&provincie=' + provincie;

//voor testen
//parent.flashmov.location.href = '../../../../flash/openmovie.html?taal=' + taal + '&deeplink=' + deeplink + '&connectie=' + connectie + '&provincie=' + provincie;
}

//voorbeeld: http://www.hollandinvideo.nl/index.html?deeplink=12&provincie=friesland
function deeplinkcheck() {
deeplink = parent.location.href;
if (deeplink.indexOf('deeplink') > 0) {
deeplinkitems = deeplink.split('?');
deeplinkitems = deeplinkitems[1];
deeplinkitems = deeplinkitems.split('=');
deeplink = deeplinkitems[1].split('&');
deeplink = deeplink[0];
provincie = deeplinkitems[2];
}
//voorbeeld: http://www.hollandinvideo.nl/index.html?provincie=friesland
else if (deeplink.indexOf('provincie') > 0) {
deeplinkitems = deeplink.split('?');
deeplinkitems = deeplinkitems[1];
deeplinkitems = deeplinkitems.split('=');
provincie = deeplinkitems[1];
window.status = 'prov=' + provincie;
deeplink = 'prov';
}
else {
deeplink = 'no';
}
}

function getValues() {
taal = GetCookie();
connectie = taal.split('&');
if (deeplink == 'no') {
provincie = connectie[2];
}
taal = taal.slice(5,8);
connectie = connectie[1];
connectie = connectie.split('=');
connectie = connectie[1];
if (deeplink == 'no') { // prov heeft status 'prov'
provincie = provincie.split('=');
provincie = provincie[1];
//alert('getvaluefunctie');
MM_showHideLayers('ned_map_a','','hide');
MM_showHideLayers('ned_map_b','','show');
MM_showHideLayers('taal','','hide');
laag = 'go_' + taal;
MM_showHideLayers(laag,'','show');
}
else { //bij deeplink meteen doorgaan
setCookie(taal,connectie,provincie);
parent.content.location.href = 'prov_' + provincie + '/html/' + taal + '/beginpagina.html';
parent.flashmov.location.href = 'flash/openmovie.html?taal=' + taal + '&deeplink=' + deeplink + '&connectie=' + connectie + '&provincie=' + provincie;
}
}

function getConnectie() {
temp = GetCookie();
connectie = temp.split('&');
connectie = connectie[1];
connectie = connectie.split('=');
connectie = connectie[1];
return connectie;
}

function ExplorerFix() {
check = parent.flashmov.location.href;
if (check.indexOf('openmovie') > 0) {
taal = parent.flashmov.location.href.split('?');
provincie = taal[1].split('=');
provincie = provincie[4];
taal = taal[1].substr(5,3);

parent.content.location.href = 'prov_' + provincie + '/html/' + taal + '/beginpagina.html';
}
}

function flashMap(pad)	{
	var movie=parent.flashmov.document.master;
	movie.SetVariable("_level0.rubriek",pad)
	movie.SetVariable("_level0.rubriekMap",pad) //dubbel nodig ivm leeggooien var door Vplayer
	movie.SetVariable("_level0.deeplink",'no')	//voorkomt vastlopen Nav na deeplink
	movie.GotoFrame(21);
	return;
}
