//
//  application.js
//  Scripts used on more than one page of the site.
//
//  Created by Ned Baldessin on 2008-08-26.
//  Copyright 2008 Ned Baldessin. All rights reserved.
//

// A transition (like Effect.Transitions.xxx) used for
// animations.
function virgin_spring(pos) {
	return 1 - (Math.cos(pos * 2 * Math.PI) * Math.exp(-pos * 10));
}

function pop(url, width, height) {
	var x = 0; var y = 0; var offset = 30;
	if (screen) { x = (screen.availWidth - width) / 2 };
	if (screen) { y = (screen.availHeight - height) / 2 };
	var popped = window.open(url,'virgin_mobile_popup','width='+width+',height='+(height)+',location=no,status=no,menubar=no,scrollbars=yes,resizable=no,screenX='+x+',screenY='+y+',left='+x+',top='+y);
	popped.focus();
	return false;
}


document.observe('dom:loaded', function(){

	if ($('minicart')) {

		$('tn-panier').observe('mouseover', function(){
			$('top-nav').addClassName('tn-panier-selected');
		})

		$('tn-panier').observe('mouseout', function(){
			$('top-nav').removeClassName('tn-panier-selected');
		})
	}

})
/*Ajout Adrien */
function openLayer(nomLayer){
	document.getElementById(nomLayer).style.display="block";
}
function closeLayer(nomLayer){
	document.getElementById(nomLayer).style.display="none";
}

function emptyField(i)
{
    switch(i){
        case '0':
            if($F('name') == 'Votre nom'){
                
                $('name').value = '';
            }
        break;
        case '1':
            if($F('firstname') == 'Votre prénom'){

                $('firstname').value = '';
            }
        break;
        case '2':
            if($F('emailFriend') == 'Votre email'){

                $('emailFriend').value = '';
            }
        break;
        case '3':
            if($F('emailfriends') == 'Emails séparés par ;'){

                $('emailfriends').value = '';
            }
        break;
        case '4':
            if($F('msgSup') == 'Votre message'){

                $('msgSup').value = '';
            }
        break;
    }
    //
    //var nbChamp = document.envoiAmiForm.button.length;
	//alert (nbChamp);
}

function trim(string)
{
	if(string == '')
		return '';
	return string.replace(/(^\s*)|(\s*$)/g, '');
}
/*Fin Ajout Adrien */
function swapOnglet(eltId) {
    arrLienId = new Array('_0','_1','_2','_3');
    intNbLienElt = new Number(arrLienId.length);
    arrClassLien = new Array('current','ghost');
	arrImage = new Array('on','off');
    strContent = new String()
        for (i=0; i<intNbLienElt; i++) {
            strContent = "menu"+arrLienId[i];
            if ( arrLienId[i] == eltId ) 
			{
                document.getElementById(arrLienId[i]).className = arrClassLien[0];
                document.getElementById(strContent).className = 'on content';
				/*Pour modifier dynamiquement l'image de l'onglet - a retirer si fond en CSS*/
				document.getElementById(arrLienId[i]).style.backgroundImage = 'url(includes/images/'+[i]+'_on.jpg)';
            } else {
				document.getElementById(arrLienId[i]).className = arrClassLien[1];
				document.getElementById(strContent).className = 'off content';
				/*Pour modifier dynamiquement l'image de l'onglet - a retirer si fond en CSS*/
				document.getElementById(arrLienId[i]).style.backgroundImage = 'url(includes/images/'+[i]+'_off.jpg)';
            }
        }
}
