function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

$(function ()
{

	var tabContainers = $('div.tabs > div');
	/*tabContainers.hide().filter(':first').show();*/

	$('div.tabs ul.tabNavigation a').click(function () {
	/* tabContainers.hide();*/
	
		/*tabContainers.filter(this.hash).show();*/
		if( this.hash == "#zoeken" )
		{
		
			$('div.tabs div.tab_content_1').show();
			$('div.tabs div.tab_content_2').hide();
			$('div.tabs div.tab_content_3').css({'position':'absolute','left':'-1000px', 'top':'-1000px'});
			$('div.tabs div.tab_content_4').hide();
		
		}
		else if( this.hash == "#aanbod" )
		{
		
			$('div.tabs div.tab_content_1').hide();
			$('div.tabs div.tab_content_2').show();
			$('div.tabs div.tab_content_3').css({'position':'absolute','left':'-1000px', 'top':'-1000px'});
			$('div.tabs div.tab_content_4').hide();
		
		}
		else if( this.hash == "#kaart" )
		{
		
			$('div.tabs div.tab_content_1').hide();
			$('div.tabs div.tab_content_2').hide();
			$('div.tabs div.tab_content_3').css({'position':'static','left':'0px','top':'0px'});
			$('div.tabs div.tab_content_4').hide();
		
		}
		
		$('div.tabs ul.tabNavigation a').removeClass('selected');
		$(this).addClass('selected');
		
		return false;
	
	}).filter(':first').click();
	
	/*1ste get tab niet nodig omdat die standaard word gekozen*/
	if( getUrlVars()["tab"] == "1" || getUrlVars()["tab"] == "2" || !isNaN( getUrlVars()["STARTPOS"] ) )
	{
	
		$('div.tabs div.tab_content_1').hide();
		$('div.tabs div.tab_content_2').show();
		$('div.tabs div.tab_content_3').css({'position':'absolute','left':'-1000px', 'top':'-1000px'});
		$('div.tabs div.tab_content_4').hide();
		
		$('div.tabs ul.tabNavigation a').removeClass('selected');
		$('#tab_aanbod').addClass('selected');
		
		return false;
		
	}
	else if( getUrlVars()["tab"] == "3" )
	{
	
		$('div.tabs div.tab_content_1').hide();
		$('div.tabs div.tab_content_2').hide();
		$('div.tabs div.tab_content_3').css({'position':'static','left':'0px','top':'0px'});
		$('div.tabs div.tab_content_4').hide();
		
		$('div.tabs ul.tabNavigation a').removeClass('selected');
		$('#tab_kaart').addClass('selected');
		
		return false;
		
	}
	
	if( !isNaN( getUrlVars()["Object"] ) )
	{
		
		$('div.tabs div.tab_content_1').hide();
		$('div.tabs div.tab_content_2').hide();
		$('div.tabs div.tab_content_3').css({'position':'absolute','left':'-1000px', 'top':'-1000px'});
		$('div.tabs div.tab_content_4').show();
		
	}
	
	/* function detail page back button */
	$('div.buttons a').click(function () {

		$('div.tabs div.tab_content_1').hide();
		$('div.tabs div.tab_content_2').show();
		$('div.tabs div.tab_content_3').css({'position':'absolute','left':'-1000px', 'top':'-1000px'});
		$('div.tabs div.tab_content_4').hide();
		
		$('div.tabs ul.tabNavigation a').removeClass('selected');
		$('div.tabs ul.tabNavigation a#tab_aanbod').addClass('selected');
		
		return false;
	
	});

});

$(document).ready(function()
{
	$('li.headlink').hover(
		function() { $('ul', this).css('display', 'block'); },
		function() { $('ul', this).css('display', 'none'); });
});

// product detail [route,reageren,doorsturen]
$(document).ready(function()
{

	$('div#form_reageren').css('display','none');
	$('div#form_doorsturen').css('display','none');
	
	// <!-- REAGEREN
	$('a#button_reageren').click(function () {
		
		$('div#form_doorsturen').css('display','none');
		$('div#form_reageren').fadeIn('slow');
	
		// Inputs (INPUTS INVISIBLE)
		$('span#r_form_visible > input').val('1');
		$('span#r_form_visible > input').css('display','none');
		
		$('span#r_object_url > input').val(location.href);
		$('span#r_object_url > input').css('display','none');
		
	});
	
	if( $('span#r_form_visible > input').val() == "1" )
	{
		
		$('div#form_doorsturen').css('display','none');
		$('div#form_reageren').css('display','block');
		
		// Inputs (INPUTS INVISIBLE)
		$('span#r_form_visible > input').val('1');
		$('span#r_form_visible > input').css('display','none');
		
		$('span#r_object_url > input').val(location.href);
		$('span#r_object_url > input').css('display','none');
		
	}
	
	if( getUrlVars()["reageren"] == "1" )
	{
		
		$('div#form_doorsturen').css('display','none');
		$('div#form_reageren').css('display','none');
		
		alert('Uw reactie is succesvol verstuurd!');
		
		window.location='Basis.aspx?Tid=' + getUrlVars()["Tid"] + '&Sid=' + getUrlVars()["Sid"] + '&Hmi=' + getUrlVars()["Hmi"] + '&Smi=' + getUrlVars()["Smi"] + '&Object=' + getUrlVars()["Object"];
		
	}
	// REAGEREN --!>
	
	// <!-- DOORSTUREN
	$('a#button_doorsturen').click(function () {
		
		$('div#form_reageren').css('display','none');
		$('div#form_doorsturen').fadeIn('slow');
		
		// Inputs (INPUTS INVISIBLE)
		$('span#d_form_visible > input').val('1');
		$('span#d_form_visible > input').css('display','none');
		
		$('span#d_object_url > input').val(location.href);
		$('span#d_object_url > input').css('display','none');
		
	});
	
	if( $('span#d_form_visible > input').val() == "1" )
	{
		
		$('div#form_reageren').css('display','none');
		$('div#form_doorsturen').css('display','block');
		
		// Inputs (INPUTS INVISIBLE)
		$('span#d_form_visible > input').val('1');
		$('span#d_form_visible > input').css('display','none');
		
		$('span#d_object_url > input').val(location.href);
		$('span#d_object_url > input').css('display','none');
		
	}
	
	if( getUrlVars()["doorsturen"] == "1" )
	{
		
		$('div#form_doorsturen').css('display','none');
		$('div#form_reageren').css('display','none');
		
		alert('U heeft succesvol deze pagina doorgestuurd!');
		
		window.location='Basis.aspx?Tid=' + getUrlVars()["Tid"] + '&Sid=' + getUrlVars()["Sid"] + '&Hmi=' + getUrlVars()["Hmi"] + '&Smi=' + getUrlVars()["Smi"] + '&Object=' + getUrlVars()["Object"];
		
	}
	// DOORSTUREN --!>

});

// check if this is a print page
var print_active = getUrlVars()["PRINT"];

if( print_active == 'TRUE' )
{

	window.print();

}

// projects details
$(document).ready(function()
{

	$('div.project_field').css('display','none');

});

function view_project_details( project_id )
{
	
	$(document).ready(function()
	{
		
			$('div.project_field').css('display','none');
			$('div#project_' + project_id).fadeIn('slow');
			$('div#project_' + project_id).css('display','block');
			
	});
	
}

// print only html tag
function print_html( content_tag )
{

	var header_str	= '<html><head><title></title></head><body>';
	var footer_str	= '</body>';
	var content_str	= document.all.item( content_tag ).innerHTML;
	var old_str		= document.body.innerHTML;
	
	document.body.innerHTML = header_str + content_str + footer_str;
	window.print(); 
	document.body.innerHTML = old_str;
	
	return false;

}