/* ALGEMENE FUNCTIES */

/*
functions 
  setExample() 
  showhide_rijen
LATEN STAAN!!!
*/

/*jQuery versie voor max aantal tekens indicator*/
function displayAantalTekens(sIdTextarea, sIdDiplay, nMaxAantal) 
{
  if ( $('#'+sIdTextarea).val().length > nMaxAantal ) {
    $('#'+sIdTextarea).val( $('#'+sIdTextarea).val().substring(0, nMaxAantal) ); 
  }		
  else {
    $('#'+sIdDiplay).html( '' + (nMaxAantal - $('#'+sIdTextarea).val().length) );
	}
}



function BrowserInfo()
{
	this.name = navigator.appName;
	this.codename = navigator.appCodeName;
	this.version = navigator.appVersion;
	this.platform = navigator.platform;
	this.javaEnabled = navigator.javaEnabled();
	this.screenWidth = screen.width;
	this.screenHeight = screen.height;
}



function getCheckedValue(radio) {
	for(i=0; i<radio.length;i++)
	{
		if (radio[i].checked) return(radio[i].value);
	}
	return("");
}


function setVisibility(obj, val)
{
	obj.style.display = val;
}

function textCounter(field, countfield, maxlimit) 
{ 
  if (field.value.length > maxlimit) 
  field.value = field.value.substring(0, maxlimit); 
  else  
  countfield.value = maxlimit - field.value.length; 
} 


function checkCookiesEnabled()
{
		//TEST of cookies zijn enabled
		//plus maak een hidden field
		Set_Cookie( 'ctest', 'none', '', '/', '', '' );
		if ( Get_Cookie( 'ctest' ) )
		{
			document.write( "<input type=hidden name=ce value=yes>" );
			Delete_Cookie('ctest', '/', '');
		}
		else
		{
			document.write( "<input type=hidden name=ce value=no>" );
		}
}



// COOKIE functies
function haalCookie(naam) 
{ 
	var zoeken = naam + "="; 
	if (document.cookie.length > 3) 
	{ 
		index1 = document.cookie.indexOf(zoeken); 
		if (index1 != -1) 
		{ 
			index1 += zoeken.length; 
			index2 = document.cookie.indexOf(";", index1); 
			if (index2 == -1) index2 = document.cookie.length; 
			return unescape(document.cookie.substring(index1, index2)); 
		} 
		else 
		{ 
			return ""; 
		} 
	}
	else 
	{ 
		return ""; 
	} 
} 

//functies van http://techpatterns.com/downloads/javascript_check_cookies.php
//
function Set_Cookie( name, value, expires, path, domain, secure ) 
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	/*if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24 */
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}
	

// this fixes an issue with the old method, ambiguous values 
// with this test document.cookie.indexOf( name + "=" );
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}				

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}


function isDate(dd,mm,yyyy)
{
	//lijkt niet te werken in MSIE 6.0, geeft altijd true
  var d = new Date(mm + "/" + dd + "/" + yyyy);
  return d.getMonth() + 1 == mm && d.getDate() == dd && d.getFullYear() == yyyy;
}

function isDate2(dd,mm,yyyy)
{
  if (dd < 1 || dd > 31) return false; //"Ongeldige dag"; 
  if (dd > 30 && (mm==4 || mm==6 || mm==9 || mm==11) ) return false; //"Ongeldige dag"; 
  if (dd > 29 && mm==2 ) return false; //"Ongeldige dag"; 
  if (mm < 1 || mm > 12) return false; //"Ongeldige maand";
	return true;
 
}

/*
OPBOUW PAGINA
/cgim/leden/mat_fotopag.pl?lftv=*lftv*&lftt=*lftt*&mv2=*mv2*&pointer={pointer}&ajax=1

-> mat_fotopag
indien ajax=1
return http.responseText


-> OBJECTEN OP PAGINA
foto foto_link
thumb1 thumb1_link
thumb2 thumb2_link
thumb3 thumb3_link
thumb4 thumb4_link
thumb5 thumb5_link

link_foto
velden

-> PROCESS
1) zet velden
2) zet fotos foto + thumb1 t/m 5
3) zet links 
4) zet pointer

//javascript
  var http = false;
  if(navigator.appName == "Microsoft Internet Explorer") {
    http = new ActiveXObject("Microsoft.XMLHTTP");
  } else {
    http = new XMLHttpRequest();
  }

 
  function volgende_vorige(go) {
    http.abort();
    http.open("GET", "/cgim/mat_nick.pl?nick="+nickname, true);
    http.onreadystatechange=function() {
      if(http.readyState == 4) {
        document.getElementById('nick_check_status').innerHTML = http.responseText;
      }
    }
    http.send(null);
  }

*/


