function thema(name,value)
{
	var today = new Date();
	today.setTime( today.getTime() );
	var path="/";
	var expires=1;
	expires = expires * 1000 * 60 * 60 * 24;
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name + "=" +escape( value ) + ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + ( ( path ) ? ";path=" + path : "" );
}

var _myElems = null; // global for the div holding the images
var _elarray = new Array(); // global for array holding files

function test(file,title,width,height, fullurl)
{
	/**
	* Other then what you would expect by its name this is actually a live function.
	* It gets called either by gb_image or by the carrosel on the product pages.
	* 
	* Create an invisible div filled with invisible thumbnails (i know..) for the
	* lightbox to create a gallery from.
	*
	* @param	file, array with files and captions to be shown in the lightbox
	* @param	title, the key + 1 of the file that should be shown first
	* @param	width, currently not in use.
	* @param	height, currently not in use.
	* @param	fullurl, boolean. If an absolute path is given, dont build url, default false.
	*/

	//FIXME: Dit kan wel wat beter/slimmer/sneller allemaal, als er eens tijd is.

	var topallowed = new Array('nl', 'de', 'be', 'fr', 'uk', 'com'); // toplevel domains
	
	if(_myElems !== null) { // remove last times thumbs
		document.body.removeChild(_myElems);
		_myElems = null;
	}	
	
	_myElems = document.createElement('div'); // thumb container
	_myElems.id = 'my_lightbox_images';
	document.body.appendChild(_myElems);
	_myElems.style.display = 'none'; // set to block for visual, not on live site plx

	_elarray = new Array();
	
	for(i = 0; i < file.length; i++) {
		if(fullurl) { // we got an absolute path
			var url = file[i].url;
		} else { // build url
			if(document.location.host == 'server') {
				var url = document.location.protocol + '//server/yoursurprise' + file[i].url;
			} else {
				var url = document.location.protocol + '//' + document.location.host + '/' + file[i].url;
			}
		}

		
		_elarray[i] = document.createElement('a'); // build anchor
		_elarray[i].id = 'hs_elem_' + i;
		_elarray[i].href = url;
		_elarray[i].title = file[i].caption;
		_myElems.appendChild(_elarray[i]); // add to container
		var im = document.createElement('img'); // build image
		im.src = url;
		im.alt = '';
		_elarray[i].appendChild(im); // add to anchor
	}

	if(document.location.host == 'server') { // development
		var imgprefix = 'http://yspnl.yspimages.net';
	} else if(document.location.host == 'surpriseatwork.nl') {
		var imgprefix = document.location.protocol + '//sawnl.yspimages.net';
	} else {
		var topl = document.location.host.split('.').pop();
		var toplevel = 'nl'; // default
		for(j = 0; j < topallowed.length; j++) { // validate toplevel
			if(topl == topallowed[j]) {
				toplevel = topallowed[j];
				break;
			}
		}
		toplevel = (toplevel == 'uk')?'couk':toplevel; // always the square peg
		var imgprefix = document.location.protocol + '//ysp' + toplevel + '.yspimages.net';
	}

	if(_elarray.length) { // at least one image is required, duh.
	
		jQuery(function() {
			// Build a lightbox, make sure it looks at our thumb div.
			// @see	jquery/jquery_lightbox.js
			jQuery('#my_lightbox_images a').lightBox({
					fixedNavigation:true,
					//overlayBgColor: '#000',
					//overlayOpacity: 0.6,
					imageLoading: imgprefix + '/assets/templates/ysp/plugins/jquery/images/lightbox-ico-loading.gif',
					imageBtnClose: imgprefix + '/assets/templates/ysp/plugins/jquery/images/close.png',
					imageBtnPrev: imgprefix + '/assets/templates/ysp/plugins/jquery/images/left.png',
					imageBtnNext: imgprefix + '/assets/templates/ysp/plugins/jquery/images/right.png',
					imageBlank: imgprefix + '/assets/templates/ysp/plugins/jquery/images/lightbox-blank.gif',
					//containerResizeSpeed: 350,
					txtImage: '',
					txtOf: '/',
					realActiveImage: (title - 1)
			});
		});
	
		var elem = document.getElementById('hs_elem_0'); // here it gets really ugly
		
		// yes, we grap the first thumb, and "click" it.
		// FIXME: this is silly.
		if( document.createEvent ) { // decent browsers
			var evObj = document.createEvent('MouseEvents');
			evObj.initEvent( 'click', true, true );
			elem.dispatchEvent(evObj);
		} else if( document.createEventObject ) { // IE...
			elem.fireEvent('onclick');
		}		

	}
}

function test1(file,title,width,height)
{
	var width = (width == null) ? "400" : width;
	var height = (height == null) ? "400" : height;
	//MOOdalBox.open(file+"," + title +"," + width + " " +  height);
	//MOOdalBox.open("assets/templates/ysp/flash/carousel/images/slab/slab_blauw_groot.jpg","Some kind of caption","500 400");
	//Lightbox.open( [["image1.jpg", "Title 1"], ["image2.jpg", "Title 2"],["image3.jpg", "Title 3"]], 0 ); 
	Lightbox.open(file, title);
}

function test2(file,title,width,height)
{
	var width = (width == null) ? "400" : width;
	var height = (height == null) ? "400" : height;
	//MOOdalBox.open(file+"," + title +"," + width + " " +  height);
	//MOOdalBox.open("assets/templates/ysp/flash/carousel/images/slab/slab_blauw_groot.jpg","Some kind of caption","500 400");
	//Lightbox.open( [["image1.jpg", "Title 1"], ["image2.jpg", "Title 2"],["image3.jpg", "Title 3"]], 0 ); 
	//Lightbox.open(file, title);
	var array=file.toString().split(","); 

	if(array.length>1 && array.length%2==0)
	{
		//alert(file);
		//alert('title' + title);
		var output='[';
		for (var i=0; i<array.length; i++) {
			output=output+'{\'caption\': \''+array[i+1]+'\', \'url\': \''+array[i]+'\'},';
		}
		var output=output+']';
		alert(output);
		GB_showImageSet(output, 1);
		// var image_set= [{'caption': 'Flower', 'url': 'http://static.flickr.com/119/294309231_a3d2a339b9.jpg'},
    //{'caption': 'Nice waterfall', 'url': 'http://www.widerange.org/images/large/plitvicka.jpg'}];
	}
	else{
		GB_show(title,file,height, width);
	}
}

/*
* Function getLink(boekje)
* @param String boekje
* het boekje waarnaar men een link wil hebben van het voorbeeldboekje
* De functie maakt een overlay en iframe waarin het boekje wordt weergegeven
*/
function getLink(boekje) {
	var link="/voorbeeldboekje?gekozenBoekje="+boekje+"";
	if(boekje != "Babyboek"){
		vriend1= document.getElementById("Vriendje_1").value;
		leeftijd = document.getElementById("Leeftijd").options[document.getElementById("Leeftijd").selectedIndex].value;
		if(vriend1 != ""){
			link += "&Vriend="+vriend1;
		}
		if(leeftijd != "-"){
			link += "&Leeftijd="+leeftijd;
		}
	}
	voornaam= document.getElementById("Voornaam_kind").value;
	achternaam= document.getElementById("Achternaam_kind").value;
	woonplaats= document.getElementById("Woonplaats_kind").value;
	naamgever= document.getElementById("Naam_van_gever").value;
	toevoeging= document.getElementById("Toevoeging").value;
	geslacht = document.getElementById("Geslacht").options[document.getElementById("Geslacht").selectedIndex].value;
	if(voornaam != ""){
		link+="&Voornaam="+voornaam;
	}
	if(achternaam != ""){
		link += "&Achternaam="+achternaam;
	}
	if(woonplaats != ""){
		link += "&Woonplaats="+woonplaats;
	}
	if(naamgever != ""){
		link += "&gegDoor="+naamgever;
	}
	if(toevoeging != ""){
		link += "&PersTekstje="+toevoeging;
	}
	link += "&Geslacht="+geslacht;
	if(boekje == "Goal"){
		WinnendTeam= document.getElementById("Winnend_team").value;
		VerliezendTeam= document.getElementById("Verliezend_team").value;
		Coach= document.getElementById("Trainer_winnend_team").value;
		Fav_Player= document.getElementById("Favoriete_speler").value;
		if(WinnendTeam != ""){
			link += "&Winteam="+WinnendTeam;
		}
		if(VerliezendTeam != ""){
			link += "&Verliesteam="+VerliezendTeam;
		}
		if(Coach != ""){
			link += "&Trainer="+Coach;
		}
		if(Fav_Player != ""){
			link += "&Voetballer="+Fav_Player;
		}
	}
	if(boekje == "Babyboek"){
		Doopnaam= document.getElementById("Doopnaam_kind").value;
		Vader= document.getElementById("Naam_vader").value;
		Moeder= document.getElementById("Naam_moeder").value;
		gebStad= document.getElementById("Geboorteplaats").value;
		gebDatum= document.getElementById("Geboortedatum").value;
		TijdUur = document.getElementById("Geboorteuur").options[document.getElementById("Geboorteuur").selectedIndex].value;
		TijdMin = document.getElementById("Geboorteminuut").options[document.getElementById("Geboorteminuut").selectedIndex].value;
		Tijd = TijdUur +":"+ TijdMin; 
		Gewicht= document.getElementById("Gewicht_kind").value;
		Lengte= document.getElementById("Lengte_kind").value;
		if(Doopnaam != ""){
			link += "&Doopnaam="+Doopnaam;
		}
		if(Vader != ""){
			link += "&Vader="+Vader;
		}
		if(Moeder != ""){
			link += "&Moeder="+Moeder;
		}
		if(gebStad != ""){
			link += "&Geboorteplaats="+gebStad;
		}
		if(gebDatum != ""){
			link += "&Geboortedatum="+gebDatum;
		}
		if(Tijd != ""){
			link += "&Tijd="+Tijd;
		}
		if(Gewicht != ""){
			link += "&Gewicht="+Gewicht;
		}
		if(Lengte != ""){
			link += "&Lengte="+Lengte;
		}
	}
	GB_show("Voorbeeld boekje",link,550,650);
}
