jQuery(document).ready(function(){

	jQuery('#Footer #SearchForm_SearchForm_Search').focus(function(){
	  if(this.value == 'Search'){
	  	this.value=''
	  }
	 });
	
	jQuery('#Form_SubscribeForm_Email').focus(function(){
	  if(this.value == 'Email Address'){
	  	this.value=''
	  }
	 });
	
	jQuery('#Form_ContactForm fieldset input').focus(function(){
	  	this.value='';
	 });
	
	jQuery('#Form_AppointmentForm fieldset input').focus(function(){
	  	this.value='';
	 });
	
	jQuery('#Form_PaymentForm fieldset input').focus(function(){
	  	this.value='';
	 });
	
	jQuery('#Form_ContactForm textarea').focus(function(){
	  	this.value='';
	 });
	
	jQuery('#Form_AppointmentForm textarea').focus(function(){
		this.value='';
	 });
	
	/*
	jQuery('#Form_SendUpdateYourWillForm_HeaderFieldBody').click(function(){
		jQuery(this).nextUntil('h2').toggle();					  
	});
	*/
	
	jQuery('#Form_SendUpdateYourWillForm_OtherTreatmentofbody').focus(function(){
		if(this.value == "Treatment of body Info"){
			this.value='';
		}
	 });
	
	
	
	var trusteeInc = 1;
	
	jQuery('#Form_SendUpdateYourWillForm_AddAnotherTrustee').click(function(){
																			
		var dupFirstName = getDupObject('TrusteesFirstName',trusteeInc);
		var dupMiddleName = getDupObject('TrusteesMiddleName',trusteeInc);
		var dupLastName = getDupObject('TrusteesLastName',trusteeInc);

		var dupOccupation = getDupObject('TrusteesOccupation',trusteeInc);
		var dupAddress = getDupObject('TrusteesAddress',trusteeInc);
		var dupSuburb = getDupObject('TrusteesSuburb',trusteeInc);
		var dupCity = getDupObject('TrusteesCity',trusteeInc);
	
		
		
		jQuery('#Form_SendUpdateYourWillForm_AddAnotherTrustee').before("<h4>Trustee "+(trusteeInc+1)+"</h4>",dupFirstName,dupMiddleName,dupLastName,dupOccupation,dupAddress,dupSuburb,dupCity);
	 	
		jQuery('#Form_SendUpdateYourWillForm_TrusteesFirstName'+trusteeInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_TrusteesMiddleName'+trusteeInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_TrusteesLastName'+trusteeInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_TrusteesOccupation'+trusteeInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_TrusteesAddress'+trusteeInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_TrusteesSuburb'+trusteeInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_TrusteesCity'+trusteeInc).attr("value","");
		
		trusteeInc++;
	 });
	
	
	var childInc = 1;
	
	jQuery('#Form_SendUpdateYourWillForm_AddAnotherChild').click(function(){
																			
		var dup1 = getDupObject('ChildsFullname',childInc);
		var dup2 = getDupObject('ChildsDOB',childInc, 'date');
		var dup3 = getDupObject('ChildsEntitlementPercentage',childInc);
	
		
		
		jQuery('#Form_SendUpdateYourWillForm_AddAnotherChild').before("<h4>Child "+(childInc+1)+"</h4>",dup1,dup2,dup3);
		
		jQuery('#Form_SendUpdateYourWillForm_ChildsFullname'+childInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_ChildsEntitlementPercentage'+childInc).attr("value","");
		
		childInc++;
	 });

	var recipientInc = 1;
	
	jQuery('#Form_SendUpdateYourWillForm_AddAnotherRecipient').click(function(){
																			
		var dup1 = getDupObject('ItemDescription',recipientInc,'textarea');
		var dup2 = getDupObject('RecipientsFullname',recipientInc);
		var dup3 = getDupObject('RecipientsOccupation',recipientInc);
		var dup4 = getDupObject('RecipientsAddress',recipientInc);
		var dup5 = getDupObject('RecipientsSuburb',recipientInc);
		var dup6 = getDupObject('RecipientsCity',recipientInc);
	
		
		
		jQuery('#Form_SendUpdateYourWillForm_AddAnotherRecipient').before("<h4>Recipient "+(recipientInc+1)+"</h4>",dup1,dup2,dup3,dup4,dup5,dup6);
		
		jQuery('#Form_SendUpdateYourWillForm_ItemDescription'+recipientInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_RecipientsFullname'+recipientInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_RecipientsOccupation'+recipientInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_RecipientsSuburb'+recipientInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_RecipientsCity'+recipientInc).attr("value","");
		
		recipientInc++;
	 });
	
	var bequestInc = 1;
	
	jQuery('#Form_SendUpdateYourWillForm_AddAnotherBequest').click(function(){
																			
		var dup1 = getDupObject('BequestAmount',bequestInc);
		var dup2 = getDupObject('BequestsFullname',bequestInc);
		var dup3 = getDupObject('BequestsOccupation',bequestInc);
		var dup4 = getDupObject('BequestsAddress',bequestInc);
		var dup5 = getDupObject('BequestsSuburb',bequestInc);
		var dup6 = getDupObject('BequestsCity',bequestInc);

		jQuery('#Form_SendUpdateYourWillForm_AddAnotherBequest').before("<h4>Bequest Recipient "+(bequestInc+1)+"</h4>",dup1,dup2,dup3,dup4,dup5,dup6);
		
		jQuery('#Form_SendUpdateYourWillForm_BequestAmount'+bequestInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_BequestsFullname'+bequestInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_BequestsOccupation'+bequestInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_BequestsAddress'+bequestInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_BequestsSuburb'+bequestInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_BequestsCity'+bequestInc).attr("value","");
		
		bequestInc++;
	
	});
	
	var propertyInc = 1;
	
	jQuery('#Form_SendUpdateYourWillForm_AddAnotherProperty').click(function(){
		
		var dup20 = getDupObject('PropertyDescription',propertyInc);
		var dup30 = getDupObject('PropertyLocation',propertyInc);
		var dup2 = getDupObject('PropertyFirstName',propertyInc);
		var dup3 = getDupObject('PropertyMiddleName',propertyInc);
		var dup4 = getDupObject('PropertyLastName',propertyInc);
		var dup5 = getDupObject('PropertyOccupation',propertyInc);
		var dup6 = getDupObject('PropertyAddress',propertyInc);
		var dup7 = getDupObject('PropertySuburb',propertyInc);
		var dup8 = getDupObject('PropertyCity',propertyInc);
	
		
		
		jQuery('#Form_SendUpdateYourWillForm_AddAnotherProperty').before("<h4>Property Recipient "+(propertyInc+1)+"</h4>",dup20,dup30,dup2,dup3,dup4,dup5,dup6,dup7,dup8);
	 
	 	//jQuery('#Form_SendUpdateYourWillForm_PropertyRealAddress'+propertyInc).attr("value","");
		//jQuery('#Form_SendUpdateYourWillForm_PropertyRealSuburb'+propertyInc).attr("value","");
		//jQuery('#Form_SendUpdateYourWillForm_PropertyRealCity'+propertyInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_PropertyDescription'+propertyInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_PropertyLocation'+propertyInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_PropertyFirstName'+propertyInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_PropertyMiddleName'+propertyInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_PropertyLastName'+propertyInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_PropertyOccupation'+propertyInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_PropertyAddress'+propertyInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_PropertySuburb'+propertyInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_PropertyCity'+propertyInc).attr("value","");
		
	 	 propertyInc++;
	 });
	 
	 var beneficiaryInc = 1;
	 
	 jQuery('#Form_SendUpdateYourWillForm_AddAnotherBeneficiary').click(function(){
		
		var dup2 = getDupObject('BeneficiaryFirstName',beneficiaryInc);
		var dup3 = getDupObject('BeneficiaryMiddleName',beneficiaryInc);
		var dup4 = getDupObject('BeneficiaryLastName',beneficiaryInc);
		var dup5 = getDupObject('BeneficiaryEntitlement',beneficiaryInc);
		var dup6 = getDupObject('BeneficiaryRelationship',beneficiaryInc);
		var dup7 = getDupObject('BeneficiaryDOB',beneficiaryInc,'date');
		var dup8 = getDupObject('BeneficiaryAgeOfEntitlement',beneficiaryInc);
		

		jQuery('#Form_SendUpdateYourWillForm_AddAnotherBeneficiary').before("<h4>Property Recipient "+(beneficiaryInc+1)+"</h4>",dup2,dup3,dup4,dup5,dup6,dup7,dup8);

		jQuery('#Form_SendUpdateYourWillForm_BeneficiaryFirstName'+beneficiaryInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_BeneficiaryMiddleName'+beneficiaryInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_BeneficiaryLastName'+beneficiaryInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_BeneficiaryEntitlement'+beneficiaryInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_BeneficiaryRelationship'+beneficiaryInc).attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_BeneficiaryAgeOfEntitlement'+beneficiaryInc).attr("value","");
		
		jQuery('#Form_SendUpdateYourWillForm_BeneficiaryDOB'+beneficiaryInc+'[Day]').attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_BeneficiaryDOB'+beneficiaryInc+'[Month]').attr("value","");
		jQuery('#Form_SendUpdateYourWillForm_BeneficiaryDOB'+beneficiaryInc+'[Year]').attr("value","");
		
	 	beneficiaryInc++;
	 });
	
	function getDupObject(idName,idUpper,type){
		
		if(type == null){
			type = 'input';
		}
		if (type == 'date') {
			type = 'input';
			return jQuery('#'+idName).clone().attr({'id':idName+idUpper}).find('label').attr({'for':'Form_SendUpdateYourWillForm_'+idName+idUpper}).parent().find(type+".day").attr({'id':'Form_SendUpdateYourWillForm_'+idName+idUpper+'[Day]', 'name':idName+idUpper+'[Day]'}).parent().find(type+".month").attr({'id':'Form_SendUpdateYourWillForm_'+idName+idUpper+'[Month]', 'name':idName+idUpper+'[Month]'}).parent().find(type+".year").attr({'id':'Form_SendUpdateYourWillForm_'+idName+idUpper+'[Year]', 'name':idName+idUpper+'[Year]'}).parents('#'+idName+idUpper);
		} else {
			return jQuery('#'+idName).clone().attr({'id':idName+idUpper}).find('label').attr({'for':'Form_SendUpdateYourWillForm_'+idName+idUpper}).parent().find(type).attr({'id':'Form_SendUpdateYourWillForm_'+idName+idUpper, 'name':idName+idUpper}).parents('#'+idName+idUpper);
		}
	}
	
	// show hide code
	
	jQuery("#Form_SendUpdateYourWillForm_OtherTreatmentofbody").hide();
	
	jQuery('#Form_SendUpdateYourWillForm_Treatmentofbody li').click(function(){
			jQuery("#Form_SendUpdateYourWillForm_OtherTreatmentofbody").hide();
	});
	
	jQuery('#Form_SendUpdateYourWillForm_Treatmentofbody li.valOther').click(function(){
			jQuery("#Form_SendUpdateYourWillForm_OtherTreatmentofbody").show();
	});	
	
	jQuery('#HasChildren').nextUntil('#Form_SendUpdateYourWillForm_HeaderFieldOther-Recipients-of-Items').hide();
	
	jQuery('#HasChildren li.valYes').click(function(){
		jQuery('#HasChildren').nextUntil('#Form_SendUpdateYourWillForm_HeaderFieldChild-1').show();
	});	
	
	jQuery('#HasChildren li.valNo').click(function(){
		jQuery('#HasChildren').nextUntil('#Form_SendUpdateYourWillForm_HeaderFieldOther-Recipients-of-Items').hide();
	});
	
	jQuery('#Form_SendUpdateYourWillForm_DetailsInSposeWill li.valYes').click(function(){
		jQuery('#DetailsInSposeWill').nextUntil('#Form_SendUpdateYourWillForm_HeaderFieldOther-Recipients-of-Items').hide();
	});
	
	jQuery('#Form_SendUpdateYourWillForm_DetailsInSposeWill li.valNo').click(function(){
		jQuery('#HasChildren').nextUntil('#Form_SendUpdateYourWillForm_HeaderFieldOther-Recipients-of-Items').show();
	});
	
	jQuery('#SpouseOrDefacto').nextUntil('#Form_SendUpdateYourWillForm_HeaderFieldTrustees').hide();
	
	jQuery('#SpouseOrDefacto li.valYes').click(function(){
		jQuery('#SpouseOrDefacto').nextUntil('#Form_SendUpdateYourWillForm_HeaderFieldTrustees').show();
	});	
	
	jQuery('#SpouseOrDefacto li.valNo').click(function(){
		jQuery('#SpouseOrDefacto').nextUntil('#Form_SendUpdateYourWillForm_HeaderFieldTrustees').hide();
	});

});

if ( jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 9 ) {
	Cufon.replace('#Menu .menuItem a',{ hover: true });
	Cufon.replace('h1');
	Cufon.replace('h2',{ hover: true });
	Cufon.replace('.headingReadMore',{ hover: true });
	Cufon.replace('.rightCol h3',{ hover: true });
	Cufon.replace('h3',{ hover: true });
	
	Cufon.replace('.mainCol blockquote p');
}


	
