// JavaScript Document

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//window.onload = MM_preloadImages('images/nav_over.gif','images/nav_last_over.jpg');


function showhide(targetid,waarde)
{
	var target = document.getElementById(targetid);
	if (waarde == 1) {
		target.style.display = "block";
	} else {
		target.style.display = "none";
	}
}

$(document).ready(function() {
	$("ul.verticaal:odd li").css("background-color","#e6e6e6");		 
	$("ul.verticaal:odd").css("background-color","#e6e6e6");		 

	$("div.formulierveldFull ul li:nth-child(even)").css("background-color","#e6e6e6");		 
	$("table.vraag tr td.sm_answer:nth-child(even)").css("background-color","#e6e6e6");		 
	$("table.vraag tr.liners:nth-child(even)").css("background-color","#e6e6e6");		 	
	/*
	var options = { 
        target:        '#loginBoodschap',   // target element(s) to be updated with server response 
        success:       reloadPage  // post-submit callback 
    };  	
    // bind form using 'ajaxForm' 
    $('#loginform').ajaxForm(options); 
	
	var opties = { 
        target:        '#loginboodschap2',   // target element(s) to be updated with server response 
        success:       reloadPage  // post-submit callback 
    };  	
    // bind form using 'ajaxForm' 
    $('#loginformulier').ajaxForm(opties); 
	*/
	var veiligheidsopties = { 
        target:        '#coderesponse',   // target element(s) to be updated with server response 
        success:       threadBlogPost  // post-submit callback 
    };  	
    // bind form using 'ajaxForm' 
    $('#reactieform').ajaxForm(veiligheidsopties); 
	initTabs(); initCampaignTabs();
});

function strpos( haystack, needle, offset){
    var i = (haystack+'').indexOf(needle, (offset ? offset : 0));
    return i === -1 ? false : i;
}

function reloadPage(status)  {
	return false;
    if (status.substring(0,11) == "<!-- OK -->") {
		url = status.substring(11);
		if (!strpos(document.location, 'country', 0)) {
			curl = document.location + url;
			location.href='http://www.theinsiders.eu/site/index.php?section=home/home' + url;
		}
		else {
			location.reload();
		}
	}
}

function threadBlogPost(status)
{
	if (status == "<!-- OK -->") {
		document.getElementById('reactie').value='';
		document.getElementById('veiligheidscode').value='';
		tekst = document.getElementById('tkst_success').value;
		$("#coderesponse").html(tekst);		
		setTimeout("location.reload();",1500);
	}
}

 
function initTabs() {
	$('#tabboxmenu a').bind('click',function(e) {
		e.preventDefault();
		var thref = $(this).attr("href").replace(/#/, '');
		$('#tabmenu a').removeClass('active');
		$(this).addClass('active');
		$('#boxcontent div.tabcontent').fadeOut(1);
		$('#'+thref).fadeIn(700);
	});
}

function initTab2() {
	$('#tabkey2').bind('click',function(e) {
		e.preventDefault();
		var thref = $(this).attr("href").replace(/#/, '');
		$('#main_camp_nav_blok a').removeClass('active');
		$('a.tbltab_2').addClass('active');
		$('#main_camp_boxcontent div.tabcontent').fadeOut(1);
		$('#tab_2').fadeIn(700);
	});
}

function initTab3() {
	$('#tabkey3').bind('click',function(e) {
		e.preventDefault();
		var thref = $(this).attr("href").replace(/#/, '');
		$('#main_camp_nav_blok a').removeClass('active');
		$('a.tbltab_3').addClass('active');
		$('#main_camp_boxcontent div.tabcontent').fadeOut(1);
		$('#tab_3').fadeIn(700);
	});
}

function initTab4() {
	$('#tabkey4').bind('click',function(e) {
		e.preventDefault();
		var thref = $(this).attr("href").replace(/#/, '');
		$('#main_camp_nav_blok a').removeClass('active');
		$('a.tbltab_4').addClass('active');
		$('#main_camp_boxcontent div.tabcontent').fadeOut(1);
		$('#tab_4').fadeIn(700);
	});
}

function initCampaignTabs() {
	$('#main_camp_nav_blok a').bind('click',function(e) {
		e.preventDefault();
		var thref = $(this).attr("href").replace(/#/, '');
		$('#main_camp_nav a').removeClass('active');
		$(this).addClass('active');
		$('#main_camp_boxcontent div.tabcontent').fadeOut(1);
		$('#'+thref).fadeIn(700);
	});		
}	

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }