/* http://www.dustindiaz.com/getelementsbyclass/ 

How it works



It’s simple. It works just how you think getElementsByClass would work, except better.



   1. Supply a class name as a string.

   2. (optional) Supply a node. This can be obtained by getElementById, or simply by just throwing in “document” (it will be document if don’t supply a node)). It’s mainly useful if you know your parent and you don’t want to loop through the entire D.O.M.

   3. (optional) Limit your results by adding a tagName. Very useful when you’re toggling checkboxes and etcetera. You could just supply “input“. Or, if you’re like me, and you said Good Bye to IE5, you can use the “*” asterisk as a catch-all (meaning ‘any element).



See getElementsByClass() in action Have Fun! 

*/

function getElementsByClass(searchClass,node,tag) {

	var classElements = new Array();

	if ( node == null )

		node = document;

	if ( tag == null )

		tag = '*';

	var els = node.getElementsByTagName(tag);

	var elsLen = els.length;

	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");

	for (i = 0, j = 0; i < elsLen; i++) {

		if ( pattern.test(els[i].className) ) {

			classElements[j] = els[i];

			j++;

		}

	}

	return classElements;

}

/* waarden van stijlen uit de stylsheet opvragen, voor zowel IE als gecko-bràwsers */

/* http://www.naarvoren.nl/artikel/css_modificatie/ */

function getRealStyle(id,styleName) {

	var element = document.getElementById(id);

	var realStyle = null;

	if (element.currentStyle)

		realStyle = element.currentStyle[styleName];

	else if (window.getComputedStyle)

	realStyle = window.getComputedStyle(element,null)[styleName];

	return realStyle;

}

function getVar(name)

/* haalt GET-variabelen uit de url */

/* http://scripts.franciscocharrua.com/javascript-get-variables.php */

         {

         get_string = document.location.search;         

         return_value = '';

         

         do { //This loop is made to catch all instances of any get variable.

            name_index = get_string.indexOf(name + '=');

            

            if(name_index != -1)

              {

              get_string = get_string.substr(name_index + name.length + 1, get_string.length - name_index);

              

              end_of_value = get_string.indexOf('&');

              if(end_of_value != -1)                

                value = get_string.substr(0, end_of_value);                

              else                

                value = get_string;                

                

              if(return_value == '' || value == '')

                 return_value += value;

              else

                 return_value += ', ' + value;

              }

            } while(name_index != -1)

            

         //Restores all the blank spaces.

         space = return_value.indexOf('+');

         while(space != -1)

              { 

              return_value = return_value.substr(0, space) + ' ' + 

              return_value.substr(space + 1, return_value.length);

							 

              space = return_value.indexOf('+');

              }

          

         return(return_value);        

         }

/** COOKIES **/

/** http://www.quirksmode.org/js/cookies.html **/

function createCookie(name,value,days) {

	if (days) {

		var date = new Date();

		date.setTime(date.getTime()+(days*24*60*60*1000));

		var expires = "; expires="+date.toGMTString();

	}

	else var expires = "";

	document.cookie = name+"="+value+expires+"; path=/";

}



function readCookie(name) {

	var nameEQ = name + "=";

	var ca = document.cookie.split(';');

	for(var i=0;i < ca.length;i++) {

		var c = ca[i];

		while (c.charAt(0)==' ') c = c.substring(1,c.length);

		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);

	}

	return null;

}



function eraseCookie(name) {

	createCookie(name,"",-1);

}

/** END COOKIES **/

/* The JavaScript Source!! http://javascript.internet.com 

 emailcheck */

function checkEmail(email) {

	return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))

}

//  End -->



function equalizeColumns() {

	P7_equalCols2(0,'LeftSet','DIV','MiddleSet','DIV','RightSet','DIV');

}



/* dynamische subnav uitzetten voor printen */

function hideSubNav() {

	subnav = getElementsByClass('SubNav');	

	for (i = 0; i < subnav.length; i++)	{

		subnav[i].style.visibility = 'hidden';

		subnav[i].style.position = 'static';

		subnav[i].style.top = -500;

//		subnav[i].style.top = '-500px';

		subnav[i].style.left = -500;

//		subnav[i].style.left = '-500px';

		subnav[i].style.zIndex = -500;

	}

	subnavitem = getElementsByClass('SubNavItem');	

	for (i = 0; i < subnavitem.length; i++)	{

		subnavitem[i].style.visibility = 'hidden';

		subnavitem[i].style.position = 'static';

		subnavitem[i].style.top = -500;

//		subnav[itemi].style.top = '-500px';

		subnavitem[i].style.left = -500;

//		subnav[itemi].style.left = '-500px';

		subnavitem[i].style.zIndex = -500;

	}

}

function showSubNav() {

	subnav = getElementsByClass('SubNav');	

	for (i = 0; i < subnav.length; i++)	{

		subnav[i].style.visibility = 'visible';

	}

	subnavitem = getElementsByClass('SubNavItem');	

	for (i = 0; i < subnavitem.length; i++)	{

		subnavitem[i].style.visibility = 'visible';

	}

}

/*************************/



/*multiple onload events*/

/* Voeg een functie toe  door OLadd('functie') */

/* run de onloadhandler zo vaak je wil door OLonload() */

function OLstart(){

	window.onload = onloadstart;

}

function onloadstart(){

	for(var i = 0;i < onloadhandlerarray.length;i++)

		eval(onloadhandlerarray[i]);

}

function OLadd(func){

	onloadhandlerarray[onloadhandlerarray.length] = func;

}

var onloadhandlerarray = new Array();



function deletep7(){

	/*removeElement('p7eq1');

	removeElement('p7eq3');

	removeElement('p7eq5');	

	OLstart();*/

	document.getElementById('p7eq1').style.paddingBottom=0;

	document.getElementById('p7eq3').style.paddingBottom=0;

	document.getElementById('p7eq5').style.paddingBottom=0;

}

/* om een flashfilmpje te kunnen besturen vanuit javascript - probleem in firefox */

function getFlashMovieObject(movieName)

{

  if (window.document[movieName]) 

  {

      return window.document[movieName];

  }

  if (navigator.appName.indexOf("Microsoft Internet")==-1)

  {

    if (document.embeds && document.embeds[movieName])

      return document.embeds[movieName]; 

  }

  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)

  {

    return document.getElementById(movieName);

  }

}	

function removeElement(id)

{

	var Node=document.getElementById(id);

	Node.parentNode.removeChild(Node);

}

	function setError(id) {
		document.getElementById('email').onfocus = function onfocus(event) {};
		document.getElementById('email').focus();
		document.getElementById(id).style.display = "block";
	}
	function newsletter_subscribe() {
		email = document.getElementById('email').value;
		echeck(email)?document.getElementById('FormNewsletter').submit():setError("NewsletterError");
	}
	function newsletter_unsubscribe() {
		document.getElementById('action').value='unsubscribe'; 
		email = document.getElementById('email').value;
		echeck(email)?document.getElementById('FormNewsletter').submit():setError("NewsletterError");
	}
/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var emailID=document.frmSample.txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }


//next line to remove IE Flickering

try { document.execCommand('BackgroundImageCache', false, true);} catch(e) {}

OLstart();


print_r = function(a, dTab) {
//initiate the return variable
var ret = "";

//the depth tabbing variable helps in indentation
if(!dTab) dTab = "\t";

//If the input variable is a collection object then iterate
if(typeof(a) == 'object'){

//foreach implementation in javascript
for(var sub in a) {
var val = a[sub];
ret += "'" + sub + "' =>";

//incase the value obtained is again a collection
if(typeof(val) == 'object') {

//drill it down by calling the print_r function recurrsively
ret += "\n" + dTab + "[" + print_r(val, dTab + "\t") + "]\n" + (dTab.substring(0, (dTab.length-1)));
} else {
ret += " \"" + val + "\"";
}
}
} else {
//Not a collection
ret = "'" + a + "' is of type '" + typeof(a) + "', not array/object.";
}
return ret;
}

