// JavaScript Document

// Start Cooking session
var jar;

// When ready.
Event.observe(document, 'dom:loaded', function(event) {


	jar = new CookieJar({
		expires:3600, // seconds
		path: '/'
	});






	// Initialize disoplayed mode (video/text)
	/*
	ui_data = jar.get('ui_data');
	
	if(ui_data == null)
	{
		jar.put('ui_data', {mode: 'ui_data_mode'});
	}
	*/
	




	
	
	
	$$('strong.tip').each(function(item,index){
		tipText = item.readAttribute('rel');

		new Tip(item, tipText, { 
			stem: 'topMiddle',
			hook: { target: 'bottomLeft', tip: 'topLeft' },
			offset: { x: 0, y: 0 }
		});
		
	});
	/**/
	


    // Set an empty value for each hyperlink who not needs tip informtion, just for ui. {SEO computing}
	$$('a.boostsign').each(function(item,index){
	    item.writeAttribute("title","");
	});
	/**/


    // Set an empty value for each hyperlink who not needs tip informtion, just for ui. {SEO computing}
	$$('img.pageTitleInfo').each(function(item,index){
	    item.writeAttribute("title","");
	    item.writeAttribute("alt","");
	});
	/**/
	



    // Fix the width size of each nav items.
	$$('a.navtab_item').each(function(item,index){
	    //
	});
	/**/



	// Mail anti spam
	if( $$('li.mailcontact a.menu_item').length>0 )
	{
	$$('li.mailcontact a.menu_item')[0].update( "boost<span class='darkness'>@</span>boost-asp.com" );
	$$('li.mailcontact a.menu_item')[0].writeAttribute('href', "mail"+"to"+":boost@boost-asp.com" );
	}
	
	if( $('LienRecrutement') )
	{
	$('LienRecrutement').update( "recrutement<span class='darkness'>@</span>boost-asp.com" );
	}
	
	// Ringback
	if( $$('li.telephone a.menu_item').length>0 )
	{
	$$('li.telephone a.menu_item')[0].writeAttribute('href', "Nous_Contacter.htm#ParTelephone" );
	}
	

	

	

    if( $('mySpaner') )
    {
	    // Create the fluidspaner component.
	    Spaner.create( 'mySpaner' , {autowidth:true, usewheel:true, prevnextloop:false, usearrowkeys:true} );
    	
	    // Fill ...
	    //$$('#Pane1 div.content')[0].update( 'Tab 1' );
	    //$$('#Pane2 div.content')[0].update( 'Tab 2' );
	    //$$('#Pane2 div.content')[0].update( 'Tab 2' );
	    


	    Spaner.slide('mySpaner','Pane1');
        /**/
    }


	// Exclude framesetting
	if (window!=top) {top.location=window.location;}


});





// AS to JS (Flash to Javascript)
var _jsNavTo = function(page)
{
/*
	new Effect.Morph('tabslider', {
		style:'width:750px',
		duration: 1.8,
		transition: Effect.Transitions.SwingFromTo,
		afterFinish: function(){
*/
			window.location = page;
/*
			new Effect.Morph('tabslider', { style:'width:0px', duration: 0.1, transition: Effect.Transitions.SwingFromTo });
		}
	});
*/
};






/*****************************************************
* popup
* 19/08/2001
*
* Open a simple nice window with url,width and height
* in arguments.
*
* --Sébastien Brémond--
* http://www.tocra.org
*****************************************************/
function openCTKFORMPopup(sURI,sWinName,w,h){
	var FULLSCREEN_const = 'no';
	
	var sh = parseInt(screen.availHeight || screen.width);
	var sw = parseInt(screen.availWidth || screen.height);
	var pH = h;
	var pW = w;
	var hasSB = (arguments.length==5)? arguments[4] :'yes' ;
	return open(sURI,sWinName,'top='+((sh-pH)/2)+',left='+((sw-pW)/2)+',width='+pW+',height='+pH+',scrollbars='+hasSB+',fullscreen='+FULLSCREEN_const);
}






function emailCheck (emailStr) {
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);

	// Verifier si le champ est vide
	if (emailStr ==''){
		 return false;
	}


	// Verifier si au format mail
	if (matchArray==null) {
		return false;
	}


	var user=matchArray[1];
	var domain=matchArray[2];

	// Verifier si des caractères ascci dans l'table étandu
	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
			return false;
	  	}
	}


	// Verifier si des caractères ascci dans l'table étandu
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			return false;
		}
	}


	// Verifier si n'est pas un nom d'utilisateur
	if (user.match(userPat)==null) {
		return false;
	}


	// Verifier si une ip valide
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {

		 for (var i=1;i<=4;i++) {
				 if (IPArray[i]>255) {
				 		return false;
	   		 }
		 }
		 return true;
	}


	// Verifier si réel domaine
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
			return false;
		}
	}


	// Verifier si tld présent valide
	if (checkTLD && domArr[domArr.length-1].length!=2 &&
		domArr[domArr.length-1].search(knownDomsPat)==-1) {
		return false;
	}


	// Make sure there's a host name preceding the domain.
	if (len<2) {
		return false;
	}


	return true;
}

