//jQuery.noConflict();    
         	
jQuery(function($) {	
	var messageElement = $('#CrisisContainer')[0]; 
	var CrisisFlagValue = $('input#CrisisFlag').val();
	
//	var CrisisAlreadyShown = getCookie("CrisisShown")
//		
//	if (CrisisAlreadyShown)
//	{
//	    $('input#CrisisFlag').val('false');
//	    CrisisFlagValue = 'false';
//	}

	if( CrisisFlagValue =='true') {
		$.blockUI({  
		 message: messageElement,
		 css: {width:'450px', height:'auto', left: '50%', marginLeft: '-225px', textAlign:'left', border:'none',cursor:'normal',	backgroundColor:'transparent' }				
		});  
		
		//setCookie('CrisisShown', CrisisFlagValue, cookieExpDate, '', '', '');
	} else {
	    document.onclick = closePopupDivs;
	}    
    $('.skip_btn').click($.unblockUI);  		
});	   

//method to close the loginpoup when clicked on the document
jQuery(document).click(function(e){

    if($(e.target).is('#Login, #Login *')){
		return;
	}
	else{
		$('#Login_Box').hide();
		$('#LoginControl').css('visibility','visible');
	}
});


$(document).ready(function(){
var pwdPwd = $('.password-password');
if( $(pwdPwd).attr('rel') == "isCookieSet" )
{
    $('.password-clear').hide();
    $('.password-password').show();
}
else
{
    $('.password-clear').show();
    $('.password-password').hide();
}

$('input.input').focus(function() {

	 var default_value = $(this).attr('rel');
	   if(this.value == default_value) {
		this.value = '';
		$(this).removeClass('defaultColor');
 
      }
  
      });
  
   $('input.input').blur(function() 
   {
     $(this).removeClass('defaultColor');
	var default_value = $(this).attr('rel');
      if(this.value == '') {
      this.value = default_value;
	   $(this).addClass('defaultColor');
	   ////RK: Release 2.0 | Enroll User | Show the Enroll div if the FGP number is not entered
	   var txtMembership = $fn(_endsWith("_txtMembershipNumberRoom"));
	   if(txtMembership!= null && txtMembership.id == this.id
	        && txtMembership.value == default_value)
	     {
	        $("div.bookingDetailWrapper div.FGP").show();
	     }   
	  }

    });
    
   
   //suresh:booking details FGP

  $('.extrWidthBxMember input.input').keyup(function(event){
  if (event.keyCode == '13') {
     event.preventDefault();
   }
  	////RK: Release 2.0 | Enroll User | Hiding the Enroll div if the FGP number is entered
  	var default_value = $(this).attr('rel');
	var txtMembership = $fn(_endsWith("_txtMembershipNumberRoom"));
       //Check if the the textbox being focussed is the membership box and its value is not same as rel text
	   if(txtMembership!= null && txtMembership.id == this.id)
	     {
	        if($("div.bookingDetailWrapper div.FGP:visible"))
	        {
	            $("div.bookingDetailWrapper div.FGP").hide();
	        }
	        if(txtMembership.value==""){
	            $("div.bookingDetailWrapper div.FGP").show();
	        }
	        
	     } 

  });
// Release R2.0 - Bhavya - this logic doesnot work in IE hence using a seperate textbox similar to bookinglogin 
//    $('.password0,.password1').blur(function() {
//	    if ($(this).val() == "" || $(this).attr('rel') == $(this).val())
//        {
//            var inputID = $(this).attr('id');
//            document.getElementById(inputID).type = "text";
//        }
//        else
//        {
//            var inputID = $(this).attr('id');
//            document.getElementById(inputID).type = "password";
////            var inputID2 = inputID.cloneNode(false);
////            inputID2.type='password';
////            inputID.parentNode.replaceChild(inputID2,inputID);             
//          
//                    
//            
//        }
//	});
	
//	$('.password0,.password1').focus(function() {
//        var inputID = $(this).attr('id')
//        //document.getElementById(inputID).type = "password"
//        document.getElementById(inputID).type = "password";
////        var inputID2 = inputID.cloneNode(false);
////            inputID2.type='password';
////            inputID.parentNode.replaceChild(inputID2,inputID);     
//	});
	
	$('input.password-clear').focus(function() {
	var txtHTMLTxtObj=$(this);
	var txtASPTxtBoxObj=$(this).prev();
	 $(txtHTMLTxtObj).hide();
	 $(txtASPTxtBoxObj).show().focus();
	});
	
	$('input.password-password').blur(function() {
	var txtHTMLTxtObj=$(this).next();
	var txtASPTxtBoxObj=$(this);
	
	if($(txtASPTxtBoxObj).val() == '') {
        $(txtHTMLTxtObj).show();
        $(txtASPTxtBoxObj).hide();
    }
	});
	
	
	
$('.pwdTxt').focus(function()
{
 $(this).hide();
 $(this).prev().show();
 $(this).prev().focus();
 if($(this).hasClass('mandatory'))
 {
 $(this).prev().addClass('mandatory'); 
 }
 
})
	
	
});




function initStatusMessage(){
if (($.browser.msie && $.browser.version == 6) || ($.browser.msie && $.browser.version == 7) )
	{
                var divObj=$('#browserMsg');
                //Res 2.2.8 - artf1232199:Scanweb - Removing IE6/IE7 alert on Select Hotel/Rate makes the listed hotels and rates disappear (It is unclear if this defect appeared after the release or if it has been there before, but it was discovered after the release)
                var ieAlertCookie =getCookie('ieCookie');
                var ieAlertDisplay = getCookie('ieAlertDisplay');
                if(ieAlertDisplay == 'true')
                {
                    if(ieAlertCookie != 'true')
                    {
                        $(divObj).show();
                    }
                }
                $(window).scroll(function()
	            {
	                $(divObj).css('position','absolute');
	                $(divObj).css('z-index','9');
	               
  		            $(divObj).animate({top:$(window).scrollTop()+"px" },{queue: false, duration: 350});  
  		            if($(window).scrollTop()==0){
  		                $(divObj).css('position','relative');
  		                $(divObj).css('z-index','9');
  		            }
  		            if($(window).scrollTop() > 0){
  		                $(divObj).css('z-index','99999');
  		               
  		            }
	            });
	            $('#close_message').click(function()
	            {
  		        //the messagebox gets scroll down with top property and gets hidden with zero opacity 
		            $(divObj).animate({ top:"+=15px",opacity:0 }, "slow");
					$(divObj).hide();
					//Res 2.2.8 - artf1232199:Scanweb - Removing IE6/IE7 alert on Select Hotel/Rate makes the listed hotels and rates disappear (It is unclear if this defect appeared after the release or if it has been there before, but it was discovered after the release)
					var date = new Date();
                    //var time = date.getTime();
                    //time += 3600*1000	
                    date.setMonth(date.getMonth() + 1);
                    //date.setTime(date.getTime()+(1*24*60*60*1000));
                    //date.setTime(time);
                    var expires = "; expires="+date.toGMTString();
				    document.cookie = "ieCookie=true"+expires+"; path=/";
		            //updateIE6MessageStatus(false);
	            });
	      }
     }
     
     /*
     $('#ctl00_FullBodyRegion_MainBodyRegion_ctl00_BookingContactDetails_txtEnrollPassword').blur(function()
     {
     alert('hello');
     $(this).removeClass('defaultColor');
	 var default_value = $(this).attr('rel');
     if(this.value == '') 
     {
         this.value = default_value;
	     $(this).addClass('defaultColor');
	   ////RK: Release 2.0 | Enroll User | Show the Enroll div if the FGP number is not entered
	     var txtMembership = $fn(_endsWith("_txtMembershipNumberRoom"));
	     if(txtMembership!= null && txtMembership.id == this.id
	        && txtMembership.value == default_value)
	     {
	        $("div.bookingDetailWrapper div.FGP").show();
	     }   
	  }
    });*/
     
     
     
     
     
$(function(){
      $('.password-password').blur(function(){
        $(this).removeClass('defaultColor');
        var default_value = $(this).attr('rel');
        if(this.value == '') 
        {
        //3423842:Password field still shows yellow| Log in module
        if($(this).hasClass('ShowColor'))
        {
        $(this).addClass('mandatory');
        $(this).next().addClass('mandatory');
        }
        $(this).next().val(default_value);
        $(this).next().show();
        $(this).hide();
        
         var txtMembership = $fn(_endsWith("_txtMembershipNumberRoom"));
	     if(txtMembership!= null && txtMembership.id == this.id
	        && txtMembership.value == default_value)
	     {
	        $("div.bookingDetailWrapper div.FGP").show();
	     } 
        }
         
    });
});
