/**
 * @author STUDIO
 * 12/05/2009
 * BAYARD BOUTIQUE
 */

var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
 
// Hides/Shows portions of form
function dynamicForm(){
		//links
		var vNewAcc = document.getElementById("newAccount");
		var vOL = document.getElementById("alreadyOL");
		var vLogEmail = document.getElementById("ipLogEmail");
		var vPwd = document.getElementById("ipPwd");
		var vNoOL = document.getElementById("notOL");
		var vFlagFromOffLine = document.getElementById("flagFromOffLine");
		var vFlagFromNewAccount = document.getElementById("flagFromNewAccount");
		var vDelEqual = document.getElementById("delivery_ipAdd_0");
		var vDelDiff = document.getElementById("delivery_ipAdd_1");
		var vDelCountry = document.getElementById("delivery_ipCountry");
		var vDelAddCountry = document.getElementById("address_ipCountry");
		var vDelCoordCountry = document.getElementById("coordonnees_ipCountry");
		
		//blocks
		var vLogin = document.getElementById("frLogin");
		var vData = document.getElementById("frTradeData");
		var vUpdateData = document.getElementById("frMyInfo");
		var vDelivery = document.getElementById("delivery");
		var vShipInt = document.getElementById("shipInt");
		
		var vFullTotInt = document.getElementById("fullTotInt");	
		var vFullTot = document.getElementById("fullTot");		
		
		//paiement
		var vCadeau = document.getElementById("chequeCadeau");
		var vCheck = document.getElementById("paycheck");
		var vCb = document.getElementById("cb");
		var vVisa = document.getElementById("visa");
        var vMaster = document.getElementById("mastercard");
		if(vCheck && vCb && vVisa && vMaster ){
			vCheck.onclick = function(){
				vCb.checked = false;
				vVisa.checked = false;
                vMaster.checked = false;
			}
			vCb.onclick = function(){
				vCheck.checked = false;

			}
			vVisa.onclick = function(){
				vCheck.checked = false;
			}
			vMaster.onclick = function(){
				vCheck.checked = false;
			}
		}

		//$("#frTradeData").css("display","none");
		$("#fsSubscriptions").css("display","none");
		
		if(vCadeau != null && vCadeau.checked == true){
			$("#hideCadeau").show();
			$("#frCheque").hide();
		}
		 
		if(vCadeau != null){
			vCadeau.onclick = function(){
				if(vCadeau.checked == true){
					$("#hideCadeau").show();
					$("#frCheque").hide();
				}else{
					$("#hideCadeau").hide();
					$("#frCheque").show();
				}
			}
		}
		
		$("#alreadyClient").click (function(){
			//$("#frLogin").toggle();
			$("#frTradeData").css("display","none");
			$("#frMyInfo").css("display","none");
		});
		$("#offline").click (function(){
			//$("#frTradeData").toggle();
			$("#frTradeData").css("display","none");
			$("#frMyInfo").css("display","block");
			vLogEmail.value = '';
			vPwd.value = '';
		});
		$("#NewAccount").click (function(){
			//$("#frTradeData").toggle();
			$("#frTradeData").css("display","block");
			$("#frMyInfo").css("display","none");
			$("#coordsCreate").css("display","none");
			$("#coordsCreateModify").css("display","block");
			$("#modifyCreate").css("display","none");
			vLogEmail.value = '';
			vPwd.value = '';
		});
		
		//if(vLogin != null && vLogin.className!="focus")
		//	vLogin.style.display = "none";
		if(vData != null && vData.className!="focus")
			vData.style.display = "none";
		if(vUpdateData != null && vUpdateData.className!="focus")
			vUpdateData.style.display = "none";
		if(vDelivery != null && vDelDiff.checked!=true)
			vDelivery.style.display = "none";
		if(vShipInt != null && (vDelCountry == null || vDelCountry.value == "FR"))
			vShipInt.style.display = "none";			

		// New account data
		/* if(vNewAcc != null){
			$("#NewAccount").click (function(){
				$("#frTradeData").css("display","block");
				$("#frLogin").css("display","none");
				//if (this.className == "lNoChecked") {
				//	this.className="lChecked";
				//	if(ie6) {this.style.backgroundImage="url(imgs/bg_radio_on.gif)";}
				//	if(ie6) {this.style.backgroundRepeat="no-repeat";}
				//	vData.style.display = "block";
				//	//vLogin.style.display = "none";
				//	vUpdateData.style.display = "none";
				//	vOL.className = "lNoChecked";
				//	if(ie6) {vOL.style.backgroundImage="url(imgs/bg_radio.gif)";}
				//	vLogEmail.value = '';
				//	vPwd.value = '';
				//	vNoOL.className = "lNoChecked";
				//	if(ie6) {vNoOL.style.backgroundImage="url(imgs/bg_radio.gif)";}
				//} else {
				//	this.className="lNoChecked";
				//	if(ie6) {this.style.backgroundImage="url(imgs/bg_radio.gif)";}
				//	vData.style.display = "none";
				//}
			});
		}
		
		//Login form
		if(vOL != null){
			vOL.onclick = function(){
				if (this.className == "lNoChecked") {
					this.className="lChecked";
					if(ie6) {this.style.backgroundImage="url(imgs/bg_radio_on.gif)";}
					if(ie6) {this.style.backgroundRepeat="no-repeat";}
					vData.style.display = "none";
					vUpdateData.style.display = "none";
					vNewAcc.className = "lNoChecked";
					if(ie6) {vNewAcc.style.backgroundImage="url(imgs/bg_radio.gif)";}
					vNoOL.className = "lNoChecked";
					if(ie6) {vNoOL.style.backgroundImage="url(imgs/bg_radio.gif)";}
				} else {
					this.className="lNoChecked";
					if(ie6) {this.style.backgroundImage="url(imgs/bg_radio.gif)";}
					//vLogin.style.display = "none";
				}
			}
		}
		//Login form
		if(vNoOL != null){
			vNoOL.onclick = function(){
				if (this.className == "lNoChecked") {
					this.className="lChecked";
					vUpdateData.style.display = "block";
					if(ie6) {this.style.backgroundImage="url(imgs/bg_radio_on.gif)";}
					if(ie6) {this.style.backgroundRepeat="no-repeat";}
					vData.style.display = "none";
					vNewAcc.className = "lNoChecked";
					if(ie6) {vNewAcc.style.backgroundImage="url(imgs/bg_radio.gif)";}
					vOL.className = "lNoChecked";
					if(ie6) {vOL.style.backgroundImage="url(imgs/bg_radio.gif)";}
					vLogEmail.value = '';
					vPwd.value = '';
				} else {
					this.className="lNoChecked";
					if(ie6) {this.style.backgroundImage="url(imgs/bg_radio.gif)";}
					vUpdateData.style.display = "none";
				}
			}
		} */
		// Login form
		if(vFlagFromOffLine != null) {
			$("#alreadyClient").attr("checked", "");
			$("#NewAccount").attr("checked", "");
			$("#offline").attr("checked", "checked");
		}
		if(vFlagFromNewAccount != null) {
			$("#alreadyClient").attr("checked", "");
			$("#NewAccount").attr("checked", "checked");
			$("#offline").attr("checked", "");
		}
		if(vLogin != null){
			$("#ipLogEmail").focus (function(){
				$("#frTradeData").css("display","none");
				$("#frMyInfo").css("display","none");
				$("#alreadyClient").attr("checked", "checked");
				$("#NewAccount").attr("checked", "");
				$("#offline").attr("checked", "");
			});
			$("#ipPwd").focus (function(){
				$("#frTradeData").css("display","none");
				$("#frMyInfo").css("display","none");
				$("#alreadyClient").attr("checked", "checked");
				$("#NewAccount").attr("checked", "");
				$("#offline").attr("checked", "");
			});
		}
		
		//Delivery form
		if(vDelDiff != null){
			vDelDiff.onclick = function(){
					vDelivery.style.display = "block";
					if(vDelCountry != null && vDelCountry.value != "FR"){
						vShipInt.style.display = "block";
						vFullTotInt.style.display = "block";
						vFullTot.style.display = "none";
					}else{
						vShipInt.style.display = "none";
						vFullTotInt.style.display = "none";
						vFullTot.style.display = "block";
					}					
			}
		}
		if(vDelEqual != null){
			if((vDelAddCountry != null && vDelAddCountry.value != "FR") || (vDelCoordCountry != null && vDelCoordCountry.value != "FR")){
				vShipInt.style.display = "block";
				vFullTotInt.style.display = "block";
				vFullTot.style.display = "none";
			}
			vDelEqual.onclick = function(){
					vDelivery.style.display = "none";
					if((vDelAddCountry != null && vDelAddCountry.value != "FR") || (vDelCoordCountry != null && vDelCoordCountry.value != "FR")){
						vShipInt.style.display = "block";
						vFullTotInt.style.display = "block";
						vFullTot.style.display = "none";
					}else{
						vShipInt.style.display = "none";
						vFullTotInt.style.display = "none";
						vFullTot.style.display = "block";
					}					
			}
		}
		if(vDelCountry != null){
			vDelCountry.onchange = function(){
				if(vDelCountry.value != "FR"){
					vShipInt.style.display = "block";
					vFullTotInt.style.display = "block";
					vFullTot.style.display = "none";
				}else{
					vShipInt.style.display = "none";
					vFullTotInt.style.display = "none";
					vFullTot.style.display = "block";
				}
			}
		}
		if(vDelAddCountry != null){
			vDelAddCountry.onchange = function(){
				if(vDelDiff.checked!=true){
					if(vDelAddCountry.value != "FR"){
						vShipInt.style.display = "block";
						vFullTotInt.style.display = "block";
						vFullTot.style.display = "none";
					}else{
						vShipInt.style.display = "none";
						vFullTotInt.style.display = "none";
						vFullTot.style.display = "block";
					}
				}
			}
		}
		if(vDelCoordCountry != null){
			vDelCoordCountry.onchange = function(){
				if(vDelDiff.checked!=true){
					if(vDelCoordCountry.value != "FR"){
						vShipInt.style.display = "block";
						vFullTotInt.style.display = "block";
						vFullTot.style.display = "none";
					}else{
						vShipInt.style.display = "none";
						vFullTotInt.style.display = "none";
						vFullTot.style.display = "block";
					}
				}
			}
		}		
}
