<!--
// for volonteer bug
var form_filled = false;

var dtCh= "/";
var minYear=1920;
var maxYear=2000;
var intervalId = 0;
var szCurrentPage = "";


var extraValidationCallbacks = null;

var validation_alerts = alerts();

function alerts(){
	var array = new Array(11);

	for( var nIndex=0; nIndex<array.length; nIndex++){
		array[ nIndex ] = new Array(5);
	}
	 
	array[0]["FR"] = "Vous devez entrer votre nom";
	array[0]["ES"] = "Rellene su apellido por favor";
	array[0]["EN"] = "Please enter your name!";
	array[0]["CN"] = array[0]["ZH"] = "请输入您的姓名";
	
	
	array[1]["FR"] = "Vous devez entrer soit votre prénom soit votre nom!";
	array[1]["ES"] = "Rellene su nombre o apellido por favor";
	array[1]["EN"] = "Please enter either your first or last name!";
	array[1]["CN"] = array[1]["ZH"] = "请输入您的姓或名";

	array[2]["FR"] = "Vous devez entrer vos coordonnées !";
	array[2]["ES"] = "Rellene sus datos por favor";
	array[2]["EN"] = "Please enter your data";
	array[2]["CN"] = array[2]["ZH"] = "请输入您的通信地址";

	array[3]["FR"] = "Vous devez entrer une adresse email valide !";
	array[3]["ES"] = "Debe rellenar una dirección válida";
	array[3]["EN"] = "Please enter a valid email";
	array[3]["CN"] = array[3]["ZH"] = "请输入您的有效电子邮箱地址";

	array[4]["FR"] = "Vous devez entrer votre numéro !";
	array[4]["ES"] = "Rellene su número de teléfono";
	array[4]["EN"] = "Please enter your phone number";
	array[4]["CN"] = array[4]["ZH"] = "请输入您的电话号码";

	array[5]["FR"] = "Vous devez entrer un numéro valide !";
	array[5]["ES"] = "Ingrese un número correcto";
	array[5]["EN"] = "Please enter a valid phone number";
	array[5]["CN"] = array[5]["ZH"] = "请输入您的有效电话号码";

	array[6]["FR"] = "Vous devez choisir un modèle de téléphone !";
	array[6]["ES"] = "Escoja un modelo de teléfono";
	array[6]["EN"] = "Please enter a phone model";
	array[6]["CN"] = array[6]["ZH"] = "请选择您的手机信号";

	array[7]["FR"] = "Vous devez entrer un code postal valide !";
	array[7]["ES"] = "Ingrese un código postal correcto";
	array[7]["EN"] = "Please enter your zip-code";
	array[7]["CN"] = array[7]["ZH"] = "请输入您的邮政编码";

	array[8]["FR"] = "Vous devez saisir une date de naissance valide !";
	array[8]["ES"] = "Debe ingresar una fecha de nacimiento válida";
	array[8]["EN"] = "Please enter a valid birthday";
	array[8]["CN"] = array[8]["ZH"] = "请输入您的有效出生日期";

	array[9]["FR"] = "Choisir \"oui\" ou \"non\" pour télécharger nos Logiciels Gratuits !";
	array[9]["ES"] = "Escoja si o no para descargar nuestra selección de softwares gratuitos";
	array[9]["EN"] = "Click 'yes' or 'no' to download our free softwares";
	array[9]["CN"] = array[9]["ZH"] = "请选择同意或不同意下载我们的免费软件";

	array[10]["FR"] = "Choisissez \"oui\" pour télécharger et utiliser nos Logiciels Gratuits.";	
	array[10]["ES"] = "Escoja si para descargar y utilizar nuestra selección de softwares gratuitos";	
	array[10]["EN"] = "Click 'yes' to download and use our free softwares";
	array[10]["CN"] = array[10]["ZH"] = "请选择同意以下载并使用我们的免费软件";

	return array;
}

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var dtCh='/';
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	
	for (var i = 1; i <= 3; i++)
		if (strYr.charAt(0)=="0" && strYr.length>1) 
			strYr=strYr.substring(1)

	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	
	if (pos1==-1 || pos2==-1)
		return false
	if (strMonth.length<1 || month<1 || month>12)
		return false
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month])
		return false
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear)
		return false
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false)
		return false
	
	return true
}

function offre_in_red ()
{
	var offre = document.getElementById ("offre");
			
	offre.style.color 		= "#FF0000";
	offre.style.fontWeight	= "bold";
			
	window.location.href 	= '#';	
}

function good_validation ()
{
	var form = window.document.forms[0];

	if (! validation ())
		return false;

	download ();
	
	return true;
}

function show_name_line()
{
	var form = window.document.forms[0];
	var name_line = document.getElementById('name_line');

	if (! name_line) return;

	for (var e=0; e<form.elements.length; e++)
		if (form.elements[e].name == 'i_offre_part[]')
			if (form.elements[e].checked == true)
			{
				name_line.style.display = '';
				return;
			}

	name_line.style.display = 'none';
}

function getElementsByClass (searchClass) {
	var classElements = new Array();
	var els = document.all || document.getElementsByTagName('*');
	
	for (i = 0, j = 0; i != els.length; i++) {
	    if ( els[i].className == searchClass ) {
			classElements[j] = els[i];
			j++;
	    }
	}
	
	return classElements;
}

function firstep () {
	var form = window.document.forms[0];

	// s'execute avant le formulaire

	switch( form.i_firstep.value  ){
		case "0": // before form
			if( clib_get_cookie ('left_skl_form') == "1"){
				
				var pRewriteManager = new RewriteManager();
				pRewriteManager.execute();
				
			
				var szHost = window.location.hostname;

				var d = new Date();
				d.setDate( d.getDate()-1 );
				clib_set_cookie ('left_skl_form', "1", d, '/', szHost );

				
				var els = getElementsByClass ('firstep_form');
				for (var key in els) 
					els[key].style.display = 'none';
					
				var els = getElementsByClass ('firstep_button');
				for (key in els)
					els[key].style.display = '';

				
				var first_button = document.getElementById ('btTelechargerGratuit');
				if( first_button )
					first_button.style.display = 'none';
					
				var second_button = document.getElementById ('btTelechargerSform');
				if( second_button )
					second_button.style.display = 'block';

				
				alert ( szMessageDeTelechargement ); // declaration et init dans skl_form
			}

			clearInterval (intervalId);	
			break;
			
		case "1": // inside form
			if( szCurrentPage != "skl_form" ){
				szCurrentPage = "skl_form";
			}
			
			var els = getElementsByClass ('firstep_form');

			for (var key in els) 
				els[key].style.display = '';
				
			var els = getElementsByClass ('firstep_button');
			for (key in els) 
				els[key].style.display = 'none';			
			
			clearInterval (intervalId);
	
			break;
			
		default:
			break;
	}
}

function firstep_submit () {
	var form = window.document.forms[0];
	
	var input = document.createElement('input');
	input.type = 'hidden';
	input.name = 'c_call';
	input.value = 'download';
	form.appendChild (input);
	form.submit();

	if (is_msie () && form.c_software && form.c_software.value)
	{
		var url = '/cgi-bin/download/direct/contact.cgi?c_call=nocontact&c_software=' + form.c_software.value +
				  '&i_campaign=' + form.i_campaign.value +
                  '&c_locale=' + form.c_locale.value +
				  '&x_randuid=' + form.x_randuid.value + '&i_sleep=1';

		window.open (url, 'Download', 'toolbar=0,location=no,directories=0,status=0, scrollbars=no,resizable=0,width=1,height=1,top=0,left=0');
	}
}

function validation ()
{
	var form = window.document.forms[0];
	var locale = form.c_locale.value.toUpperCase();
	

			 
	if( form.c_sex && !form.c_sex[0].checked && !form.c_sex[1].checked )
	{
		alert ( validation_alerts[2][locale] );	
		return false;
	}
	
	
	
	var name_line = document.getElementById('name_line');
	if ( name_line && name_line.style.display != 'none' )
	{
		if (! form.c_nom.value)
		{
			alert ( validation_alerts[0][locale] );	
			return false;
		}
	}

	if ( form.c_name && ! form.c_name.value )
	{
		alert ( validation_alerts[1][locale] );
		return false;
	}

	if (! form.e_email.value)
	{
		alert ( validation_alerts[3][locale] );	
		return false;
	}

	if (! check_e_prefix (form.e_email.value))
	{
		alert ( validation_alerts[3][locale] );	
		return false;
	}


	if ( 	(form.i_birthday_d && ! form.i_birthday_d[form.i_birthday_d.selectedIndex].value) ||
			(form.i_birthday_m && ! form.i_birthday_m[form.i_birthday_m.selectedIndex].value) ||
			(form.i_birthday_y && ! form.i_birthday_y[form.i_birthday_y.selectedIndex].value) ){
		alert ( validation_alerts[8][locale] );	
		return false;
	}

	if(form.i_birthday_m) {
		var birthday = form.i_birthday_m.value + "/" + form.i_birthday_d.value + "/" + form.i_birthday_y.value;
		if( !isDate(birthday)){
			alert ( validation_alerts[8][locale] );
			return false;
		}
	}	
	
	
	if (form.p_cp)
	{
		var bAlert = false;
		
		if( ! form.p_cp.value || !check_i_prefix (form.p_cp.value) ){
			alert ( validation_alerts[7][locale] );
			return false;
		}
		
	
		switch( form.c_locale.value.toLowerCase() ){
			case 'fr':
				bAlert = form.p_cp.value.length != 5 && form.p_cp.value.length != 2;
			break;
			
			case 'zh':
			case 'cn':
				bAlert = form.p_cp.value.length != 6;
			break;
			
			case 'es':
			case 'en':
				bAlert = form.p_cp.value.length != 5;
			break;			
		}

		if( bAlert ){
			alert ( validation_alerts[7][locale] );
			return false;
		}
		
	} 



	
	if (form.t_portable && ! form.t_portable.value)
	{
		alert ( validation_alerts[4][locale] );	
		return false;
	}

	if (form.t_portable && ! check_t_prefix (form.t_portable.value,locale))
	{
		alert ( validation_alerts[5][locale] );	
		return false;
	}


	if ( form.c_portableMarque && form.c_portableMarque.selectedIndex == 0)
	{
		alert ( validation_alerts[6][locale] );	
		return false;
	}

	
	

	


	if (form.i_ads_form && form.i_ads_form.value && form.i_ads)
	{
		if ((form.i_ads_form.value == 1) && ! (form.i_ads[0].checked || form.i_ads[1].checked))
		{
			offre_in_red ();
	
			alert ( validation_alerts[9][locale] );
			return false;
		}

		if ((form.i_ads_form.value == 2) && ! form.i_ads[0].checked)
		{
			offre_in_red ();

			alert ( validation_alerts[10][locale] );
			return false;
		}

		if ((form.i_ads_form.value == 3) && ! form.i_ads.checked)
		{
			return false;
		}
	}	
	

	if( extraValidationCallbacks && extraValidationCallbacks.length > 0 ){
		if( !runValidationCallbacks() ){
			return false;
		}
	}
	
	
	
	return true;
}



function download ()
{
	var form = document.forms[0];

	// MSIS => Microsoft Internet Explorer
	if (is_msie () && form.c_software && form.c_software.value)
	{
	
		var url = '/cgi-bin/download/direct/contact.cgi?c_call=nocontact&c_software=' + form.c_software.value +
				  '&i_campaign=' + form.i_campaign.value + 
				  '&e_email=' + form.e_email.value +
                                  '&c_locale=' + form.c_locale.value +
				  '&x_randuid=' + form.x_randuid.value + '&i_sleep=1';

		if (form.i_birthday_d)
		{
			url += '&i_birthday_d=' + form.i_birthday_d[form.i_birthday_d.selectedIndex].value +
				   '&i_birthday_m=' + form.i_birthday_m[form.i_birthday_m.selectedIndex].value +
				   '&i_birthday_y=' + form.i_birthday_y[form.i_birthday_y.selectedIndex].value;
		}
		
		if (form.p_cp)
		{
			url += '&p_cp=' + form.p_cp.value;
		}
		
		if (form.t_portable)
		{
			url += '&t_portable=' + form.t_portable.value;
		}
		
		if (form.c_sex)
		{
			if (form.c_sex[0].checked)
			{
				url += '&c_sex=' + form.c_sex[0].value;
			}
			if (form.c_sex[1].checked)
			{
				url += '&c_sex=' + form.c_sex[1].value;
			}		 
		}
		
		if (form.i_ads_form && form.i_ads)
		{
			if (form.i_ads_form.value == 1 || form.i_ads_form.value == 2)
			{ 
				if (form.i_ads[0].checked)
				{
					url += '&i_ads=' + form.i_ads[0].value;
				}
				if (form.i_ads[1].checked)
				{
					url += '&i_ads=' + form.i_ads[1].value;
				}		 
			}
						
			if (form.i_ads_form.value == 3)
			{
					url += '&i_ads=' + form.i_ads.value;
			}
		}
		
		if (form.x_prize64)
		{
			url += '&x_prize64=' + form.x_prize64.value;
		}
		
	
		if (form.i_extra_form && form.i_extra_form.value == 0 || (form.i_firstep && form.i_firstep.value == 1)) {
			var win = window.open (url, 'Download', 'toolbar=0,location=no,directories=0,status=0, scrollbars=no,resizable=0,width=1,height=1,top=0,left=0');
	
			if (win)
				win.focus ();
		}
	}
	
	// for volonteer bug
	form_filled = true;
	
	return true;
}

function switch_submission ()
{
	var form = document.forms[0];
	
	if (form.i_ads)
	{
		if (form.i_ads.checked){
			if (form.x_submit)
				form.x_submit.disabled = false;
		}
		else{
			if (form.x_submit)
				form.x_submit.disabled = true;
		}
	}
	
	
}

function init ()
{
	var form = document.forms[0];
	
	if (! form) return;

	if (form.i_ads)
	{
		if (form.i_ads.checked){
			if (form.x_submit)
				form.x_submit.disabled = false;
		}
		else{
			if (form.x_submit)
				form.x_submit.disabled = true;
		}
	}

	intervalId = setInterval (firstep, 100);
}


function removeValidationCallback(callback){
	var nBefore = 0;
	var nAfter = 0;

	// if its null then abort
	if( !callback || !extraValidationCallbacks )	
		return false;
		
	// check current size;
	nBefore = extraValidationCallbacks.length;

	for(var nIndex=0; nIndex<nBefore; nIndex++){
		if( extraValidationCallbacks[ nIndex ] == callback ){
			extraValidationCallbacks.splice(nIndex,1);
			
			// check new size
			nAfter = extraValidationCallbacks.length;
			
			return nAfter < nBefore
		}
	}	

	return false;
}

function insertNewValidationCallback(callback){
	var nBefore = 0;
	var nAfter = 0;
	
	// if its null then abort
	if( !callback )	
		return false;
	
	// if its empty then create array
	if( !extraValidationCallbacks )
		extraValidationCallbacks = new Array();
	
	// check current size;
	nBefore = extraValidationCallbacks.length;
	
	// add new callack to the stack
	extraValidationCallbacks.push( callback );
	
	// check new size
	nAfter = extraValidationCallbacks.length;

	// return adding result
	return nAfter > nBefore;
}

function runValidationCallbacks(){
	// get array size
	var nSize = extraValidationCallbacks.length;

	// run through the array and execute each callback
	for( nIndex=0; nIndex < nSize; nIndex++ ){
		var bSuccess = extraValidationCallbacks[ nIndex ]();
		
		if( !bSuccess )
			return false;
	}

	return true;
}


function onLeavingPage(){
	// TODO: MAKE YOUR ONQUIT SCRIPTS HERE
	
	
	
	switch( szCurrentPage ){
		case "skl_form":
			var szHost = window.location.hostname;

			var d = new Date;
			d.setTime( d.getTime() + 15000 );
			// d.setTime( d.getTime() + 120000 );
			
			var name = clib_set_cookie ('left_skl_form', "1", d, '/', szHost );			

			// alert(name);
			
			
			break;
		
		default:
			break;
	}
}






window.onunload = onLeavingPage;
window.onload=init;
//-->
