/*
 * ***** BEGIN LICENSE BLOCK *****
 *
 * This file is part of MediaIdea Project.
 * Copyright (c) 2007 MediaIdea Technologies. All rights
 * reserved.
 *
 * ***** END LICENSE BLOCK *****
 */

//var path = 'http://'+window.location.host+'/';
//var path = 'http://www.salut-les-filles.com/';


var path = '/';

function do_auth(){
	
	var opt = {		
		evalScripts: true,
		method: 'post',
		//parameters: {p: 'rrr'},
		parameters: { login: $('login').value, passwd: $('passwd').value, task: 'authentification' },
		onComplete: function(requete){
			Element.update('info_auth', requete.responseText);
			if ($('auth_ok')){
				Form.disable('form_auth');
			}
		}
	}
	
	new Ajax.Request(path+'layout/__ajax_request.php', opt);
}

function do_inscription(form){
	
	new Effect.ScrollTo('info_inscription', {offset : -100 });
	
	var opt = {
		evalScripts: true,
		parameters: Form.serialize(form)+'&task=inscription',
		onComplete: function(requete){
			Element.update('info_inscription', requete.responseText);
			
			if ($('inscription_ok')){
				setTimeout("top.location.href = 'validation.html'", 100); 			
			}
		}
	}
	new Ajax.Request(path+'layout/__ajax_request.php', opt);	
}


function do_verif_adr_livr(){
	
	if ($('adr_livraison_true').checked == true){
		Element.hide('adr_livraison');
	}
	else {
		Element.show('adr_livraison');
	}
}



function countClicPartenaire(idCampagne){

	var opt = {
		evalScripts: true,
		parameters: 'id='+idCampagne+'&task=countClic',
		onComplete: function(requete){
			Element.update('testDiv', requete.responseText);
		}
	}		
	new Ajax.Request(path+'layout/__ajax_request.php', opt);
}

function productToShowroom(idProduct, idShowroom){

	var opt = {
		evalScripts: true,
		parameters: 'prod_id='+idProduct+'&showroom_id='+idShowroom+'&task=productToShowroom',
		onComplete: function(requete){
			if(requete.responseText == ''){
				alert('Vous avez atteint votre limite de produits selectionnes.');
			}
			else {
				
				Element.update('libCheckProduct'+idProduct, requete.responseText);
				
				var className = Element.classNames($('imgCheck'+idProduct));
				var nbShowroom = parseInt($('nbShowroom').innerHTML);
				
				if (className == 'imgOk'){
					var newValeur = nbShowroom+1;	
				}
				else{
					var newValeur = nbShowroom-1;
				}
				
				Element.update('nbShowroom', newValeur);
			}
		}
	}
	
	new Ajax.Request(path+'layout/__ajax_request.php', opt);
}
