function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else{
		ro = new XMLHttpRequest();
	}
	return ro;
}

var browser = navigator.appName;
var http = createRequestObject();

if(browser == "Microsoft Internet Explorer"){
	var meth = "POST";
}
else{
	var meth = "GET";
}

function slideSwitch() {
    var $active = $('#home_fotos IMG.active');

    if ( $active.length == 0 ) $active = $('#home_fotos IMG:last');

   		var $next =  $active.next().length ? $active.next()
        : $('#home_fotos IMG:first');

	    $active.addClass('last-active');

    	$next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
        $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});

function pagSwitch() {
    var $active = $('#pag_fotos IMG.active');

    if ( $active.length == 0 ) $active = $('#pag_fotos IMG:last');

   		var $next =  $active.next().length ? $active.next()
        : $('#pag_fotos IMG:first');

	    $active.addClass('last-active');

    	$next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
        $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "pagSwitch()", 5000 );
});

/*$(function() {
	$.nyroModalSettings({
		debug: false,
		width: null,
		height: null,
		minWidth:1026,
		minHeight: 602,
		processHandler: function(settings) {
			var url = settings.url;
			if (url && url.indexOf('http://www.youtube.com/watch?v=') == 0) {
				$.nyroModalSettings({
					type: 'swf',
					width: null,
					height: null,
					minWidth: 800,
					minHeight: 600,
					url: url.replace(new RegExp("watch\\?v=", "i"), 'v/')
				});
			}
		},
		endShowContent: function(elts, settings) {
			$('.resizeLink', elts.contentWrapper).click(function(e) {
				e.preventDefault();
				$.nyroModalSettings({
				width: null,
				height: null,
			    minWidth: 800,
			    minHeight: 600,
				});
				return false;
			});
			$('.bgLink', elts.contentWrapper).click(function(e) {
				e.preventDefault();
				$.nyroModalSettings({
					bgColor: '#'+parseInt(255*Math.random()).toString(16)+parseInt(255*Math.random()).toString(16)+parseInt(255*Math.random()).toString(16)
				});
				return false;
			});
		}
	});
	
	function preloadImg(image) {
		var img = new Image();
		img.src = image;
	}
	var mom = document.getElementById('mom').value;
	preloadImg(mom+'img/modal/ajaxLoader.gif');
	preloadImg(mom+'img/modal/prev.gif');
	preloadImg(mom+'img/modal/close.gif');
	preloadImg(mom+'img/modal/next.gif');
	
	
});*/

function favoriet(){
	if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  		window.external.AddFavorite("http://www.countrygolfees.nl","Country Golf Ees - Short Golf 4 all");
	} 
	else if (navigator.appName == "Netscape") {
    	window.sidebar.addPanel("Country Golf Ees - Short Golf 4 all","http://www.countrygolfees.nl","");
	}
}

function selPrevPhoto(){
 	var mom = document.getElementById("mom").value;
	var momfoto = document.getElementById('momfoto').value;
	var aantal = document.getElementById('aantal').value;
	
	if(eval(momfoto) - eval(1) > 0){
		var foto = eval(momfoto) - eval(1);
		
		document.getElementById('momfoto').value = foto;
	}
	else{
		var foto = aantal;
		
		document.getElementById('momfoto').value = aantal;
	}
	
	document.getElementById('foto_groot').src = mom+"album/groot_"+document.getElementById('foto_'+foto).value;
	
}

function selNextPhoto(){
 	var mom = document.getElementById("mom").value;
	var momfoto = document.getElementById('momfoto').value;
	var aantal = document.getElementById('aantal').value;
	
	if((eval(momfoto) + eval(1)) <= aantal){
		var foto = (eval(momfoto) + eval(1));
		
		document.getElementById('momfoto').value = foto;
	}
	else{
		var foto = 1;
		
		document.getElementById('momfoto').value = 1;
	}
	
	document.getElementById('foto_groot').src = mom+"album/groot_"+document.getElementById('foto_'+foto).value;
	
}

function contrReservering(){
	
}

function contrContact(){
	
}

function selPhoto(foto){
	document.getElementById('foto_groot').src = foto;
}

function plattegrond() {
 	var mom = document.getElementById("mom").value;


	if (GBrowserIsCompatible()) {
			
		var map = new GMap2(document.getElementById("maps"));

		 map.setCenter(new GLatLng(52.90686382696852,6.813325881958008), 17);
		
		 map.addControl(new GLargeMapControl());
		 map.addControl(new GMapTypeControl());
		 map.setMapType(G_HYBRID_MAP);
		 icon = new GIcon();
		 icon.image = mom+"img/CGE-route-vlaggetje.png";
		 icon.iconSize = new GSize(72, 77);
		 icon.iconAnchor = new GPoint(1,1);
		 icon.infoWindowAnchor = new GPoint(5, 1);
		
		 marker=new GMarker(new GLatLng(52.90686382696852,6.813325881958008), icon);
		 map.addOverlay(marker);
	}
}
