var status = jQuery.cookie("dpdhl_advanced_search_status");

jQuery(document).ready(function() {

 if (status == "opened") {
      jQuery('#advancedSearch').css("display", "block");
      jQuery('#topSearchControls .controlEle').css("display", "none");
      jQuery("a#advancedSearchButtonClosed").hide();
      jQuery("a#advancedSearchButtonOpened").show();  
    }    
      
   jQuery("a#advancedSearchButtonClosed").click(function() {

     jQuery("a#advancedSearchButtonClosed").hide();
     jQuery("a#advancedSearchButtonOpened").show();  
     jQuery('#advancedSearch').css("display", "block");
     jQuery('#topSearchControls .controlEle').css("display", "none"); 
     jQuery.cookie("dpdhl_advanced_search_status", "opened"); 
   });
   
    jQuery("a#advancedSearchButtonOpened").click(function() {

       jQuery("a#advancedSearchButtonOpened").hide();
       jQuery("a#advancedSearchButtonClosed").show();  
       jQuery('#advancedSearch').css("display", "none");
       jQuery('#topSearchControls .controlEle').css("display", "block"); 
       jQuery.cookie("dpdhl_advanced_search_status", null);
    });
 
      
  var btnYellow = jQuery('a.nextButton, a.btnSearchCareer, a.profileButton, a.mngCvButton, a.viewDoc, a.deleteDoc, a.uploadDoc, a.profileButton, a.tellFriendButton, a.sendJobsButton, a.viewJobsButton, a.withdrawButton, a.applyButton, .arButton, a.newAgent, a.viewAgent, a.deleteAgent, a.updateAgentPref, a.emailPassword, a.yesButton, a.noButton, a.printView').wrapInner('<span class="new" />');    
  jQuery(btnYellow).prepend('<span class="btn-left" />');
  jQuery(btnYellow).append('<span class="btn-right" />');
  
  var btnYellowBig = jQuery('a.bigApplyButton').wrapInner('<span class="newBig" />');    
  jQuery(btnYellowBig).prepend('<span class="btn-big-left" />');
  jQuery(btnYellowBig).append('<span class="btn-big-right" />');
  
  var btnGrey = jQuery('a.greyButton, a.backButton').wrapInner('<span class="newGrey" />');    
  jQuery(btnGrey).prepend('<span class="btn-gr-left" />');
  jQuery(btnGrey).append('<span class="btn-gr-right" />');  
    
  jQuery('a.nextButton, a.greyButton, a.bigApplyButton, a.btnSearchCareer, a.backButton, a.profileButton, a.mngCvButton, a.viewDoc, a.deleteDoc, a.uploadDoc, a.profileButton, a.tellFriendButton, a.sendJobsButton, a.viewJobsButton, a.withdrawButton, a.applyButton, .arButton, a.newAgent, a.viewAgent, a.deleteAgent, a.updateAgentPref, a.emailPassword, a.yesButton, a.noButton, a.printView').wrap('<table class="fixButton" border="0" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>');  
  
  jQuery('input[type=text], input[type=password], input#password, input#placeHolder, input[name="j_captcha_response"]').addClass("standardInputField");
                
  jQuery('#placeHolder').focus(function() {
          jQuery('#placeHolder').hide();
          jQuery('#password').show();
          jQuery('#password').focus();
          jQuery('#placeHolder').hide();
  });
     
  jQuery('#password').blur(function() { 
          if(jQuery('#password').val() == '') {
          jQuery('#placeHolder').show();
          jQuery('#password').hide();
          }   
    }); 
    
    // Description: Dynamic calculate width of first two input fields based on width of >>in<< and >>or<< in specific language.    
    
    // 1.1 Default width for >>in<< (ENUK / ENUS without padding left/right)
    var defaultWidthIn = "12";
    
    // 1.2 Default width for >>or<< (ENUK / ENUS without padding left/right)
    var defaultWidthOr = "11";
    
    // 2.1 Get width of first input for keywords
    var defaultWidthSearchFieldKeywords = jQuery("#searchFieldKeywords").width();
    
    // 2.2 Get width of first input for keywords
    var defaultWidthSearchFieldRefNo = jQuery("#searchFieldRefNo").width();
    
    // 3. Substract default width from current width
    var newDiffWidthIn = jQuery("#searchFieldIn").width() - defaultWidthIn;
    var newDiffWidthOr = jQuery("#searchFieldOr").width() - defaultWidthOr;
    
    // 4. Add new width to keywords and ref no fields
    var newWidthSearchFieldKeywords = defaultWidthSearchFieldKeywords - newDiffWidthIn;
    var newWidthSearchFieldRefNo = defaultWidthSearchFieldRefNo - newDiffWidthOr;
    
    // 5. Use new width f
    jQuery("#searchFieldKeywords, #searchFieldKeywords input").width(newWidthSearchFieldKeywords);
    jQuery("#searchFieldRefNo, #searchFieldRefNo input").width(newWidthSearchFieldRefNo);
    
});
