var AJAX_ROOT = ROOT+'includes/includes/process.php';

/**
*	externalLinks - target blank aan link klappen
*/
function externalLinks()
{
	if (!document.getElementsByTagName) return;
	
	var anchors = document.getElementsByTagName("a");
	
	var i;
	for(i=0; i<anchors.length; i++)
	{
		var anchor = anchors[i];
		
		if(anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
	}
}
window.onload = externalLinks;

/**
*	in_array - kijk of een waarde voorkomt in een array
*/
function in_array (needle, haystack, start)
{  
	if(start == '')
		start = 0;

	var result = haystack.indexOf(needle, start);
	if ( result > -1 )
		return true;
	else
		return false;
}

/**
*
*/
function publishPoll(id, type)
{
	$.post(AJAX_ROOT, {action: 'publishPoll', value: id, actie: type}, function(data)
	{
		window.location = window.location;
	});
}

/**
*
*/
function publishCamping(id, type)
{
	$.post(AJAX_ROOT, {action: 'publishCamping', value: id, actie: type}, function(data)
	{
		window.location = window.location;
	});
}

/**
*
*/
function publishLastMinute(id, type)
{
	$.post(AJAX_ROOT, {action: 'publishLastMinute', value: id, actie: type}, function(data)
	{
		window.location = window.location;
	});
}

/**
*	vote
*/
function vote(id, no_vote)
{
	if(id != null)
	{
		$.post(AJAX_ROOT, { action: 'vote', value: id, result: no_vote }, function(data)
		{
			$('#poll_').html(data);
		})
	}
}

/**
*
*/
function happyPopUp(code, affid)
{
	var plus = (affid != null && affid != '' ? "&affiliate_id="+affid : "")
	
	var hoog = (screen.height - 610) / 2;
	var links = (screen.width - 880) / 2;
	
	var mydate = new Date();
		
	//window.open("http://www.virtueelboeken.nl/index.asp?u=2245&objecttype="+code+"&movetodatum=01-06-2009", "VR", "toolbar=0,location=0,status=1,menubar=0,scrollbars=0,resizable=0,width=880,height=660,top="+hoog+",left="+links);
	
	var url = "http://www.virtueelboeken.nl/index.asp?u=2245&type=concernbeschikbaarheid&objecttype="+code+"&movetodatum=01-06-2012" + plus+"";
	//alert(url);
	window.open(""+url+"", "VR", "toolbar=0,location=0,status=1,menubar=0,scrollbars=0,resizable=0,width=865,height=660,top="+hoog+",left="+links);
}

function happyFullLink(url, affid)
{
	var plus = (affid != null && affid != '' ? "&affiliate_id="+affid : "")
	
	var hoog = (screen.height - 610) / 2;
	var links = (screen.width - 880) / 2;

	window.open(url+plus, "VR", "toolbar=0,location=0,status=1,menubar=0,scrollbars=0,resizable=0,width=880,height=660,top="+hoog+",left="+links);
}

/**
*
*/
function happyBrochure(code, affid) {
	
	var plus = (affid != null && affid != '' ? "&affiliate_id="+affid : "")
		
	
	var hoog = (screen.height - 610) / 2;
	var links = (screen.width - 880) / 2;
	
	if(code != "")
	{
		window.open("http://www.virtueelboeken.nl/index.asp?u=2245"+code+""+plus, "VR", "toolbar=0,location=0,status=1,menubar=0,scrollbars=0,resizable=0,width=880,height=660,top="+hoog+",left="+links);
		//window.open("http://www.virtueelboeken.nl/index.asp?u=2245&type=concernbeschikbaarheid&objecttype="+code, "VR", "toolbar=0,location=0,status=1,menubar=0,scrollbars=0,resizable=0,width=880,height=660,top="+hoog+",left="+links);
	}else{
		window.open("http://www.virtueelboeken.nl/index.asp?u=2245"+plus, "VR", "toolbar=0,location=0,status=1,menubar=0,scrollbars=0,resizable=0,width=880,height=660,top="+hoog+",left="+links);
		//window.open("http://www.virtueelboeken.nl/index.asp?u=2245&type=concernbeschikbaarheid", "VR", "toolbar=0,location=0,status=1,menubar=0,scrollbars=0,resizable=0,width=880,height=660,top="+hoog+",left="+links);
	}
}

/**
*
*/
function happyZoekEnBoek(affid)
{
	var plus = (affid != null && affid != '' ? "&affiliate_id="+affid : "")
	
	var hoog = (screen.height - 610) / 2;
	var links = (screen.width - 880) / 2;
	
	window.open("http://www.virtueelboeken.nl/index.asp?u=2245&type=concernbeschikbaarheid&movetodatum=01-06-2012"+plus, "VR", "toolbar=0,location=0,status=1,menubar=0,scrollbars=0,resizable=0,width=880,height=660,top="+hoog+",left="+links);
}

/*/
 *
 */
function mapPopUp(URL)
{
    day = new Date();
    id  = day.getTime();
    
    var hoog = (screen.height - 200) / 2;
    var links = (screen.width - 520) / 2;
    
    window.open(""+URL+"", "" + id + "", 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=520,height=200,left = '+links+',top = '+hoog);
}

/**
*	changeTitle = verander titel
*/
function changeTitle(title)
{
	document.title = title;
}

/**
*
*/
function switchLastMinute()
{
	$.post(AJAX_ROOT, { action: 'switch', value: $('#switch').attr('rel') }, function(data)
	{
		if($('#switch').attr('rel') == 'a')
		{
			$('#switch').attr('rel', 'l');
			$('#switch').val('Switch naar lastminutes');
			$('#switcher').html("Aanbiedingen");
		}
		else
		{
			$('#switch').attr('rel', 'a');
			$('#switch').val('Switch naar aanbiedingen');
			$('#switcher').html("Lastminutes");
		}
	});
}

$(document).ready(function()
{
	// --- corners
	$('.corner').corner();
	$('#blader_online').corner("bl br 10px");
	
	$('.antwoorden').toggle(function()
	{
		var id 	= $(this).attr('id');
		id 		= id.substr(9);
		
		$('#results_'+id).slideDown(500);
	}, function()
	{
		var id 	= $(this).attr('id');
		id 		= id.substr(9);
		
		$('#results_'+id).slideUp(500);
	});
	
	/*logo bounce*/
	$('#happytent').animate({paddingTop: '+=60px'}, 300);
	$('#happytent').animate({paddingTop: '-=10px'}, 100);
	$('#happytent').animate({paddingTop: '+=10px'}, 50);
	
/*
 	$('.location')
		.bind("mouseenter",function () {			
		   $(this).find('.location_content').show();
		})
		.bind("mouseleave",function () {
		    //$(this).find('.location_content').hide();
		    // $(this).find('.location_content').delay(4000).hide();
		   // setTimeout('$(".location_content").hide()',1500);
		   $(this).find('.location_content').delay(2000).slideUp('slow');
	});
	*/

/*
	$(".location, .location_content").hover(
	  function () {
	    $(this).find('.location_content').show();
	  }, 
	  function () {
	    //setTimeout('$(".location_content").hide()',1500);
	  	$(this).find('.location_content').delay(2000).slideUp('slow');
	  }
	);
	*/	
});


