	$(function(){
					
			// Dialog			
				$('#terms').dialog({
					autoOpen: false,
					width: 455,
					height: 440,
					resizable: false,
					modal:true
				});
				
				// Dialog Link
				$('#dialog_link_terms').click(function(){
					window.location = "/resource?page.action=ShowContent&contentType=terms&Content_Id=Terms Of Use";
					return false;
				});
				
				$('#traveltips_link').click(function() {
					window.location = "/resource?page.action=ShowContent";
					return false;
				});
				//hover states on the static widgets
				$('#dialog_link_terms, ul#icons li').hover(
					function() { $(this).addClass('ui-state-hover'); }, 
					function() { $(this).removeClass('ui-state-hover'); }
				);
				
				
				$('#interest').dialog({
					autoOpen: false,
					width: 455,
					height: 240,
					resizable: false,
					modal:true
				});
				
				$('#dialog_link_interest').click(function(){
					window.location = "/resource?page.action=ShowContent&contentType=privacy&Content_Id=Privacy Policy";
					return false;
				});
				
				$('.okButton').click(function(){
					$('.interest').dialog('close');
					return false;
				});
				
				$('#terms_closeText').click(function(){
					$('.terms').dialog('close');
					return false;
				});
				
				$('#interest_closeText').click(function(){
					$('.interest').dialog('close');
					return false;
				});
				
				$('.terms_acceptBtn').click(function(){
					$('.terms').dialog('close');
					return false;
				});
				
				$('.terms_donotAcceptBtn').click(function(){
					$('.terms').dialog('close');
					return false;
				});
				
				$("#AboutUs").click(function(){
					window.location = "/resource?page.action=ShowContent&contentType=aboutus&Content_Id=About Us";
				});
				$("#siteMap").click(function(){
					window.location = "/sitemap.jsp";
				});
				
			
				$("#CancellationPolicy").click(function(){
					//$.showHelp("Cancellation and Refund Policy");
					window.location = "/resource?page.action=ShowContent&contentType=crpolicy&Content_Id=Cancellation And Refund Policy";
				});
				
				/*$("#Survey").click(function(){
					//$.showDialog("Survey", "This is a temporary text. <br /> Redirect to Survey.");
				});*/
				
				$("#Facebook").click(function(){
					window.open("http://www.facebook.com/home.php#/pages/Discover91/120848538209");
				});
				
				$("#Twitter").click(function() {
				    window.open("http://twitter.com/Discover91");
				});

				
				/* Contact Form / Enquiry */
				$('#QuestionsDialog').dialog({
					autoOpen: false,
					width: 455,
					height: 440,
					resizable: false,
					modal:true
				});
				
					$("#contact_link, .contactUsCommon, .holiday_enquiry_link, .experience_enquiry_link").click(function() {
					// Need to check if the dialog need to be put before setting the value
					var enquiryType = "general";

					$("#QuestionsDialog").dialog('open');
					$("#enquiry_from").focus();

					if ($(this).hasClass("generalEnquiry") || $(this).hasClass("contactUsCommon")) {
						enquiryType = "general";
					}  
					else if ($(this).hasClass("holiday_enquiry_link")) {
						enquiryType = "holiday";
					} else if ($(this).hasClass("experience_enquiry_link")) {
						enquiryType = "experience";
					}
					$("#enquiry_type").val(enquiryType);
					// the "type" parameters need to change for a different link
					var urlBase = "/enquiry", urlParam = "&page.action=show&enquiry_type=" + enquiryType;
					
					// here goes the code for fetching the data from the server
					$.getJSON(urlBase, urlParam, function(data) {
						// here put the code to set the variables
						var strTo = "", strFrom = "", strSubject="", strBody = "";
						if (data) {
							strTo = data["ui.mail.toaddress"];
							strFrom = data["ui.mail.fromaddress"];
							strSubject = data["ui.mail.subject"];
							strBody = data["ui.mail.bodytext"];
						}
						$("#enquiry_to").val(strTo);
						if(strFrom == null || strFrom=="" || strFrom == "Your email here..."){
							$('#enquiry_from').attr("readonly",false);
							$("#enquiry_from").rules("add","email");
							}else{
								$("#enquiry_from").val(strFrom);
								$('#enquiry_from').attr("readonly",true);
								$("#enquiry_from").rules("remove","email");
								}
						$("#enquiry_subject").val(strSubject);
						$("#enquiry_question").val(strBody);
					});

				});
				
				$("#enquiry_question").click(function() {
				if($("#enquiry_question").val() == "Please enter your questions here..." ){
                $(this).focus();
                $(this).select();
				}
      		      });

				$("#formEnquiry").validate({ 
					focusCleanup: true,
					onkeyup: false,
					rules: { 
					  enquiry_subject: {
						required: true,
						maxlength: 64
						},
						enquiry_from:{
						required: true,
						notEqualTo: "Your email here...",
						maxlength: 50
						},
					  enquiry_question:{
						required: true,
						notEqualTo: "Please enter your questions here..."
						}
					}, 
					messages: { 
					  enquiry_subject: {
						required: "Subject is a mandatory field",
						maxlength: "Max 64 characters allowed"
						},
					  enquiry_from:{
						required: "Invalid Email Address",
						email: "Invalid Email Address",
						notEqualTo: "Invalid Email Address",
						maxlength: "Max 50 characters allowed"
							},
					 enquiry_question:{
						required: "Question is a mandatory field",
						notEqualTo: "Invalid Question"
						}
					}
				}); 
			
				$('#enquiry_close').bind('click',function(){
					$("#QuestionsDialog").dialog('close');
				});
			
							
				//Sijo - Sending enquiry ajax JSON request
				$('#enquiry_submit').bind('click', function() {
					if($("#formEnquiry").valid()){
						$.getJSON("/enquiry?page.action=post&TimeStamp="+ new Date(), $("#formEnquiry").serialize(), function(data){
							if (data.code == 0) {
								$("#QuestionsDialog").dialog('close');
								$.showAlert("Successful Operation","Your question has been posted successfully.");
								
							}
							else {
								$.showAlert("Unsuccessful Operation","There was an error occured while posting your question"+ data.message);
								
							}
						});
					}
					return false;
				});
				$('.QuestionsDialogClose').click(function() { 
					$("#QuestionsDialog").dialog('close');
				});
			});