function initialize(){
	$('collection').style.display = 'none';
    $('watchrs').style.display = 'none';
  var pars = $F('brand_collection');
  var url = "/brand/request_brand_collection";
  var myAjax = new Ajax.Request(
  url,{
    method: 'post',
    requestHeaders: ['User-Agent','ajax_call'],
    postBody: 'option='+pars,
    onSuccess: requesterInit
  });
}





function requesterInit(t){
	 $('collection').innerHTML = t.responseText;
evalScripts(t.responseText);
    $('collection').style.display = 'inline';


  if(typeof(currency) == "undefined"){
    currency = "undefined";
  }
 
$('watchrs').style.display = 'none';
  var pars = 1 ;
  
  var url = "/brand/request_collection_watch";
  var myAjax = new Ajax.Request(
  url,{
    method: 'post',
    requestHeaders: ['User-Agent','ajax_call'],
    postBody: 'option='+pars+'&currency='+currency,
    onSuccess: requesterwatchInit
  });

}



function requesterwatchInit(t){
	
   $('watchrs').innerHTML = t.responseText;
	evalScripts(t.responseText)
   $('watchrs').style.display = 'inline';
   update_bank_cart_currency();


}

function select_brand_option()
{
	
   $('collection').style.display = 'none';
    $('watchrs').style.display = 'none';
  var pars = $F('brand_collection');
  var url = "/brand/request_brand_collection";
  var myAjax = new Ajax.Request(
  url,{
    method: 'post',
    requestHeaders: ['User-Agent','ajax_call'],
    postBody: 'option='+pars,
    onSuccess: requester
  });
}

function select_currency()
{
  donne = $F('currency');
  select_collection_watch(donne);  
  
}



function add_to_shoping_cart(refnumber)
{
    //    $('clockwatch').style.display = 'inline';
  var url = "/shoping/add_to_shoping_cart";
  var myAjax = new Ajax.Request(
  url,{
    method: 'post',
    requestHeaders: ['User-Agent','ajax_call'],
    postBody: 'refnumber='+refnumber,
    onSuccess: requester_shop
  });
}



function change_currency()
{

    // select_collection_watch($F('currency'));  
  var url = "/brand/change_currency";
  var myAjax = new Ajax.Request(
  url,{
    method: 'post',
    requestHeaders: ['User-Agent','ajax_call'],
    postBody: 'currency='+ $F('currency'),
    onSuccess: nothingtodo
  });
}
function nothingtodo(t)
{
window.location.reload(true); 
}
function requester_shop(t)
{
    $('add_to_cart_mess').innerHTML = "<span class = 'en' lang = 'en'>Your watch has been added to the shopping cart. Click the shopping cart icon for a summary of the items chosen and to finalize your order </span><span class = 'fr' lang = 'fr'>Votre montre &agrave; &eacute;t&eacute; ajout&eacute; dans le panier d'achat. Cliquer sur le lien panier d'achat pour avoir un sommaire des articles choisis et pour finaliser la commande.</span> ";

        switchlang();
    //    $('clockwatch').style.display = 'none';
    //	$('bankshop').innerHTML = t.responseText
}




function buyaction()
{
   var myAjax = new Ajax.Request(
  url,{
    method: 'post',
    requestHeaders: ['User-Agent','ajax_call'],
    postBody: pars,
    onSuccess: requestwrappershop
  });
}

function requester(t)
{
  $('collection').innerHTML = t.responseText;
    $('collection').style.display = 'inline';
}

function requesterwatch(t)
{
  $('watchrs').innerHTML = t.responseText;
   $('watchrs').style.display = 'inline';
   //   update_bank_cart_currency();
}

function requestwrappershop(t)
{
  $('wrappershop').innerHTML = t.responseText;
}

function sac(){
	
}


function checkout_validation(lang)
{
	var bok = true;
	//prv_list

	if($('sship').innerHTML == "" || $F('country') == "")
	{
		bok = false;
	}
	
	if($('prv_list').style.display != "none" && $F('states') == "")
	{
		bok = false;
	}
	
	if(bok == false && lang == "en")
	{
		alert("required field!");
	}
	else if(bok == false )
	{
		alert("champs obligatoire manquant!");
	}

	return bok;
}

function checkout(){
  
	if(!checkout_validation('en'))
	{
		return false;
		
	}
	else
	{
		var pars = "";
		var taxe_price = 0;
		if($('shipPrice').innerHTML != "")
		{
			pars +="shipping_price=" + $('shipPrice').innerHTML;
			pars +="&shipingmethod=" + $('hi_ship_methode').value;
		}
		
		if($("TR_ID_14" ).style.display != "none")
		{ 
			taxe_price = taxe_price + parseFloat($("PX_ID_14" ).innerHTML);
		}
		if($("TR_ID_15" ).style.display != "none")
		{
			taxe_price = taxe_price + parseFloat($("PX_ID_15" ).innerHTML);
		}
		if($("TR_ID_16" ).style.display != "none")
		{
			taxe_price = taxe_price + parseFloat($("PX_ID_16" ).innerHTML);
		}
		if(taxe_price != 0)
		{
			if(pars == "")
			{
				pars += "taxes=" + taxe_price;
			}
			else
			{
				pars += "&taxes=" + taxe_price;
			}
		}
		
	  var url = "/shoping/checkout";
	  var myAjax = new Ajax.Request(
	  url,{
	    method: 'post',
	    requestHeaders: ['User-Agent','ajax_call'],
	    onSuccess: requestcheckout,
		postBody:pars
	  });
	}
}
function checkoutDeal(){
  

	  var url = "/shoping/checkoutDeal";
	  var myAjax = new Ajax.Request(
	  url,{
	    method: 'post',
	    requestHeaders: ['User-Agent','ajax_call'],
	    onSuccess: requestcheckout
	  });
	
}
function requestcheckout(t)
{
  $('checkout').innerHTML = t.responseText;


switchlang();

}

