// JavaScript Document
// Created 14oct2009 ktp

var updateUserAddressForm = function(){
                   //alert('now');
	//Do not display the Country input item and label...do not need for JP (field not displayed in either)
	//pkg:but display in case of product sku page
                    $("dt:contains('Country')").not("#WineInfo dt:contains('Country')").hide();
        
	$("dd:contains('Choose a Country')").hide();
	
	//Do not display the Title input item and label...JP below
	$("dt:contains('Title')").hide();
	//for JP
	$("dt:contains('JP_Title')").hide();
	//Selects the parent of FormField_29, which is the dd element
	$('input#FormField_29').parent().hide();
	$("dt:contains('この住所を保存する')").hide();
	$("dd:contains('Yes, save this address to my address book')").hide();

	//Modify display for shipping address edit
	$("#ShippingAddressForm #AddressEditForm dt:contains('生年月日')").hide();
	$("#ShippingAddressForm #AddressEditForm dt:contains('Birth')").hide();
	$('#ShippingAddressForm #AddressEditForm #FormField_36').parent().hide();

	//Modify display for additional shipping address on checkout form
	$("div.ExpressCheckoutContent form#NewShippingAddress dt:contains('生年月日')").hide();
	$("div.ExpressCheckoutContent form#NewShippingAddress dt:contains('Birth')").hide();
	$('div.ExpressCheckoutContent form#NewShippingAddress #FormField_37').parent().hide();
	
	//Do not display the Ship to This Address input item and label...JP below
	// $("dt:contains('Title')").addClass('DontShowFormElement');
	//for JP
	// $("dt:contains('届け先にする')").addClass('DontShowFormElement');
	//Selects the parent of FormField_29, which is the dd element
	// $('div#FormField_15').parent().addClass('DontShowFormElement');
	
	
	//Hide the <p> element at the start of the BlockContent
	//Can put in different text advice at a future time
	$('#CreateAccountForm div.BlockContent p:first').hide();

	//var loc = window.location;
	//var pathName = loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 1);
	//var isB2B = (pathName.lastIndexOf('b2b')>0)?true:false;
	
	
	if($('.FormComment').length){
	}else{
		
		//Add <span> element after each input element with a name of FormField
		$('input[name^=FormField]').after("<span>Example Text</span>");
		$('div#FormField_36').after("<div>Example Text</div>");
	        
		//Add <span> element after each input element with a specific id
		$('input#account_firstname').after("<span>Example Text</span>");
		$('input#account_lastname').after("<span>Example Text</span>");

		// Add CSS class to all comments
		$("span:contains('Ex')").addClass('FormComment');
		$("div:contains('Example')").addClass('FormCommentNewLine');
		
		//pkg: this append is wrong , you cant append span inside input box
		//$('#FormField_1').append("<span></span>");
		//Siva: right, but the purpose is different, so we need to fix this by removing the .after("<span>Example Text</span>");
		// pkg updated need to combine with updatepagedisplay.js; updated coz it was generating error as header is replaced by partner header
		var themeLang=($('body').is('#_en'))?'en':'jp';
		if(themeLang == "jp"){
			//Make Japanese page values
			//Set form comment text for each form input item
			$('#FormField_1~span').text("例: winefan@iwine.jp (ログインID) ").append("<br/><b>*携帯メールでのご登録の場合はPCメールの受信が許可されていることを確認してください。*</b>");
			$('#FormField_2~span').text("6-20 文字");
			$('#FormField_3~span').text("6-20 文字");
			$('#FormField_4~span').text("例: 太郎");
			$('#FormField_5~span').text("例: 山田");
			$('#FormField_6~span').text("");
			$('#FormField_7~span').text("例: 03-1234-5678");
			$('#FormField_8~span').text("例: 西馬込 1-2-12");
			$('#FormField_9~span').text("例: ベイサイドマンション３０５号室");
			$('#FormField_10~span').text("例: 品川区 または 多摩川市");
			$('#FormField_13~span').text("例: 105-0014");
			$("option:contains('Choose a Prefecture')").text('都道府県をお選びください');
			
			$('#FormField_16~span').text("例: 太郎");
			$('#FormField_17~span').text("例: 山田");
			$('#FormField_18~span').text("");
			$('#FormField_19~span').text("例: 03-1234-5678");
			$('#FormField_20~span').text("例: 西馬込 1-2-12");
			$('#FormField_21~span').text("例: ベイサイドマンション３０５号室");
			$('#FormField_22~span').text("例: 品川区 または 多摩川市");
			$('#FormField_25~span').text("例: 105-0014");

			$('#FormField_36~div').text("未成年者の飲酒は法律により禁止されております。");

			$('#account_firstname~span').text("例: 太郎");
			$('#account_lastname~span').text("例: 山田");
			$('#FormField_15 label').html('<input id="FormField_15_0" name="FormField[2][15][0]" value="Yes, ship to this address" class="FormFieldOption" checked="checked" type="checkbox"> この住所を送付先として利用');

			//if(isB2B==true){
			//}
		}else{
			//Make English page values
			//Set form comment text for each form input item
			$('#FormField_1~span').text("Ex: winefan@iwine.jp (LoginID)");
			$('#FormField_2~span').text("6 to 20 characters");
			$('#FormField_3~span').text("6 to 20 characters");
			$('#FormField_4~span').text("Ex: Robert");
			$('#FormField_5~span').text("Ex: Mondavi");
			$('#FormField_6~span').text("");
			$('#FormField_7~span').text("Ex: 03-1234-5678");
			$('#FormField_8~span').text("Ex: Nishi-magome 1-2-12");
			$('#FormField_9~span').text("Ex: Lions Mansion #413");
			$('#FormField_10~span').text("Ex: Shingawa-ku or Tamagawa-shi");
			$('#FormField_13~span').text("Ex: 105-0014");
			
			$('#FormField_16~span').text("Ex: Robert");
			$('#FormField_17~span').text("Ex: Mondavi");
			$('#FormField_18~span').text("");
			$('#FormField_19~span').text("Ex: 03-1234-5678");
			$('#FormField_20~span').text("Ex: Nishi-magome 1-2-12");
			$('#FormField_21~span').text("Ex: Lions Mansion #413");
			$('#FormField_22~span').text("Ex: Shingawa-ku or Tamagawa-shi");
			$('#FormField_25~span').text("Ex: 105-0014");
			//$('#FormField_29~span').text("");

			$('#FormField_36~div').text("You must be 20 years of age to purchase alcohol.");

			$('#account_firstname~span').text("Ex: Robert");
			$('#account_lastname~span').text("Ex: Mondavi");
			//if(isB2B==true){
			//}
		}
                zipButton();
	}
        // Remove all text from any remaining Example Text instances
	$("span:contains('Example')").text('');
};


$(document).ready(updateUserAddressForm);


