// 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];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function changeDisplay(id) {
	var obj=document.getElementById(id);
	if(obj.style.display == '' || obj.style.display == 'none') obj.style.display = 'block';
	else obj.style.display = 'none';
}

function changeVisibility(id) {
	var obj=document.getElementById(id);
	if(obj.style.visibility == 'hidden' || obj.style.visibility == '') { 
		obj.style.visibility = 'visible'; 
	}
	else obj.style.visibility = 'hidden';
}

function centerInViewport(id) {
	var objref=document.getElementById(id);
	var ie=document.all && !window.opera;	
	iebody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
	var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset;
	var docwidth=(ie)? iebody.clientWidth : window.innerWidth;
	docheight=(ie)? iebody.clientHeight: window.innerHeight;
	var objwidth=objref.offsetWidth;
	objheight=objref.offsetHeight;
	objref.style.left=(docwidth/2-objwidth/2)+130+"px";
	objref.style.top=scroll_top+docheight/2-objheight/2+"px";
}
function show(id) {
	var obj=document.getElementById(id);
	obj.style.display = '';
	
	reFoot(document.getElementById('registration').style.height);
}

function hide(id) {
	var obj=document.getElementById(id);
	obj.style.display = 'none';
	
	reFoot(document.getElementById('registration').style.height);
}

function reFoot(size){
	document.getElementById('content2').style.height = size;
	document.getElementById('footer').style.position = 'relative';
}

function is18(value, lang){
	validation = false;
	
	var dateFormat = /^\d{2}\/\d{2}\/\d{4}/;
	// 2/2/2006 || 02/02/2006
	
	if(dateFormat.test(value)) {
		FullDate = value.split('/');
		base_year = FullDate[2];
		
		if(lang == "en") {
			base_day = FullDate[1];
			base_month = FullDate[0];
		} else {
			base_day = FullDate[0];
			base_month = FullDate[1];
		}
		
		d = new Date();
		current_day		= d.getDate();
		current_mon		= d.getMonth();
		current_yr		= d.getFullYear();
		
		base_day = (base_day.charAt(0) == 0) ? base_day.substr(1,1) : base_day;
		base_month = (base_month.charAt(0) == 0) ? base_month.substr(1,1) : base_month;
		
		dateArray = date_diff(base_year, base_month, base_day);
		//alert(dateArray['year']+','+dateArray['month']+','+dateArray['day']);
		//alert('day:'+base_day+',month:'+base_month+',year:'+base_year);
		
		
		if(current_yr - base_year < 18){ 
			validation = false;
		}else if(current_yr - base_year == 18 && (dateArray['month'] >= 1 || dateArray['day'] >= 1)){  
			validation = false;
		}else{
			validation = true;
		}
			
	}else {
		validation = false;
	}
	
	return validation;
}

function date_diff(start_year, start_month, start_day){
	base_day	= start_day;			// no leading "0"
	base_mon	= start_month;			// no leading "0"
	base_yr	= start_year;		// use 4 digit years!
	
	d = new Date();
	current_day		= d.getDate();
	current_mon		= d.getMonth();
	current_yr		= d.getFullYear();
	
	// and now .... calculate the difference! :-)
	
	// overflow is always caused by max days of base_mon
	// so we need to know how many days base_mon had
	
	//base_mon_max		= new Date(base_yr,base_mon,base_day,0,0,0,0);
	base_mon_max = 32 - new Date(base_yr, base_mon, 32).getDate();
	if((base_mon == 2) && (base_yr % 400 == 0)){
		base_mon_max = 29;
	}else if((base_mon == 2) && (base_yr % 400 != 0)){
		base_mon_max = 28;
	}
	
	// days left till the end of that month
	base_day_diff 		= base_mon_max - base_day;
	
	// month left till end of that year
	// substract one to handle overflow correctly
	base_mon_diff 		= 12 - base_mon - 1;
	
	// start on jan 1st of the next year
	start_day		= 1;
	start_mon		= 1;
	start_yr		= base_yr + 1;
	
	// difference to that 1st of jan
	day_diff	= (current_day - start_day) + 1; 	// add today
	mon_diff	= (current_mon - start_mon) + 1;	// add current month
	yr_diff	= (current_yr - start_yr);
	
	// and add the rest of base_yr
	day_diff	= day_diff + base_day_diff;
	mon_diff	= mon_diff + base_mon_diff;
	
	// handle overflow of days
	if (day_diff >= base_mon_max)
	{
		day_diff = day_diff - base_mon_max;
		mon_diff = mon_diff + 1;
	}
	
	// handle overflow of years
	if (mon_diff >= 12)
	{
		mon_diff = mon_diff - 12;
		yr_diff = yr_diff + 1;
	}
	diff = new Array();
	diff['year'] = yr_diff;
	diff['month'] = mon_diff;
	diff['day'] = day_diff;
	
	return diff;
}
//-->