//if (window.location.protocol == "https:" && location.pathname.indexOf('/marketplace/gift_card/') == -1 && location.host != "news.bahamabreeze.com"){
//   window.location = window.location.href.replace('https','http')
//}

var js_server_path = location.pathname.replace('.asp','');
var js_pathparts = js_server_path.split("/");

var root_path = '';
if (location.host == "news.bahamabreeze.com" && location.href.indexOf('_051010') == -1){
   root_path = "//www.bahamabreeze.com";
}
else if (location.host == "artgallery.bahamabreeze.com"){
   root_path = "http://www.bahamabreeze.com";
}
else if (location.host == "checkout.bahamabreeze.com"){
   root_path = "http://www.bahamabreeze.com";
}
else if (location.host == "news.bahamabreeze.com" && location.href.indexOf('_051010') != -1){
   root_path = "http://stage.bahamabreeze.com";
}
else if (location.host == "test-bahamabreeze.researchhq.com"){
   root_path = "http://demo.bahamabreeze.com";
}
else if (location.host == "stage.bahamabreeze.com"){
   root_path = "http://stage.bahamabreeze.com";
}
else if (location.host == "bahamabreeze.researchhq.com"){
   root_path = "http://www.bahamabreeze.com";
}
else if (location.host != "bahama-breeze-dev.realbranding-test.com" && location.host != "www.bahamabreeze.com" && location.host != "demo.bahamabreeze.com"){
   root_path = "http://www.bahamabreeze.com";
}

if (location.search == '?force_root_path') root_path = "http://"+location.host;
if (root_path != '' && location.search == '?check_root_path') alert(root_path);

// if (root_path != '' && window.location.protocol == "https:") root_path.replace(/http:/, "https:");

// BEGIN HITBOX VARIABLES
if (location.host == "stage.bahamabreeze.com" || location.host == "demo.bahamabreeze.com" || location.host == "test-bahamabreeze.researchhq.com"){
   var hbx_account_number = "DM540930L6EM";
}
else{   
   var hbx_account_number = "DM540930ACWM";
}
var content_cat = "";
if (location.host == "www.bahamabreeze.com" || location.host == "stage.bahamabreeze.com" || location.host == "demo.bahamabreeze.com" || location.host == "bahama-breeze-dev.realbranding-test.com"){
   var content_categories = new Object;
   content_categories['menus'] = "Menus";
   content_categories['survey'] = "Survey";
   content_categories['insiders'] = "Island Insiders";
   content_categories['tour'] = "Take The Tour";
   content_categories['marketplace'] = "Gift Cards";
   content_categories['recipes'] = "Recipes";
   content_categories['careers'] = "Jobs";
   content_categories['company'] = "Company";
   content_categories['legal'] = "Legal";
   content_categories['faq'] = "FAQ";
   content_categories['search'] = "Search";
   content_categories['island_spotlight'] = "Island Spotlight";
   content_categories['messagebottle'] = "Message in a Bottle";
   content_categories['mno'] = "Mothers Night Out";
   
   var top_level_directory;
   top_level_directory = js_pathparts[1];
   if (content_categories[top_level_directory]){
      content_cat = content_categories[top_level_directory];
   }
   else if (js_pathparts[1].indexOf('Default_nf') != -1 || js_pathparts[1].indexOf('default_nf') != -1){
      content_cat = "Home Page Non Flash";
   }
   else if (js_pathparts[1].indexOf('Default') != -1 || js_pathparts[1].indexOf('default') != -1){
      content_cat = "Home Page";
   }
   else if (js_pathparts[1] == ""){
      content_cat = "Home Page";
   }
   else if (js_pathparts[2] == ""){
      content_cat = "Root";
   }
   else{
      content_cat = "Other";
   }
}
else if (location.host == "news.bahamabreeze.com" && location.href.indexOf('invite') != -1){
   content_cat = "Invite a Friend";
}
else if (location.host == "news.bahamabreeze.com" && location.href.indexOf('mib') != -1){
   content_cat = "Message in a Bottle";
}
else if (location.host == "news.bahamabreeze.com"){
   content_cat = "Island Insiders";
}
else if (location.host == "artgallery.bahamabreeze.com"){
   content_cat = "Bruce Smith Art Gallery";
}
else if (location.host == "checkout.bahamabreeze.com"){
   content_cat = "Bruce Smith Art Gallery";
}
else if (location.host.indexOf('freefind') != -1){
   content_cat = "Search";
}
else if (location.host.indexOf('where2getit') != -1 && location.search.indexOf('invite') != -1){
   content_cat = "Invite a Friend";
}
else if (location.host.indexOf('where2getit') != -1){
   content_cat = "Restaurant Locator";
}
else if (location.host.indexOf('researchhq') != -1){
   content_cat = "Survey";
}
else if (location.host.indexOf('realbranding') != -1){
   content_cat = "RealBranding Test";
}
else{
   content_cat = "Other (third party)";
}

// END HITBOX VARIABLES

if(document.images){

   // BEGIN MAIN NAVIGATION PRELOADS
   
   home = new Image(49,20);
   home.src = root_path+"/images/nav_main/home.gif";
   
   home_over = new Image(49,20);
   home_over.src = root_path+"/images/nav_main/home_over.gif";
   
   menus = new Image(84,20);
   menus.src = root_path+"/images/nav_main/menus.gif";
   
   menus_on = new Image(84,20);
   menus_on.src = root_path+"/images/nav_main/menus_on.gif";
   
   menus_over = new Image(84,20);
   menus_over.src = root_path+"/images/nav_main/menus_over.gif";
   
   survey = new Image(63,20);
   survey.src = root_path+"/images/nav_main/survey.gif";
   
   survey_on = new Image(63,20);
   survey_on.src = root_path+"/images/nav_main/survey_on.gif";
   
   survey_over = new Image(63,20);
   survey_over.src = root_path+"/images/nav_main/survey_over.gif";
   
   insiders = new Image(124,20);
   insiders.src = root_path+"/images/nav_main/insiders.gif";
   
   insiders_on = new Image(124,20);
   insiders_on.src = root_path+"/images/nav_main/insiders_on.gif";
   
   insiders_over = new Image(124,20);
   insiders_over.src = root_path+"/images/nav_main/insiders_over.gif";
   
   join_insiders = new Image(132,20);
   join_insiders.src = root_path+"/images/nav_main/join_insiders.gif";
   
   join_insiders_on = new Image(132,20);
   join_insiders_on.src = root_path+"/images/nav_main/join_insiders_on.gif";
   
   join_insiders_over = new Image(132,20);
   join_insiders_over.src = root_path+"/images/nav_main/join_insiders_over.gif";   
   
   document.write("<!-- :::"+join_insiders_over+"::: -->");
   
   tour = new Image(120,20);
   tour.src = root_path+"/images/nav_main/tour.gif";
   
   tour_on = new Image(120,20);
   tour_on.src = root_path+"/images/nav_main/tour_on.gif";
   
   tour_over = new Image(120,20);
   tour_over.src = root_path+"/images/nav_main/tour_over.gif";
   
   gift_card = new Image(85,20);
   gift_card.src = root_path+"/images/nav_main/gift_card.gif";
   
   gift_card_on = new Image(85,20);
   gift_card_on.src = root_path+"/images/nav_main/gift_card_on.gif";
   
   gift_card_over = new Image(85,20);
   gift_card_over.src = root_path+"/images/nav_main/gift_card_over.gif";
   
   recipes = new Image(68,20);
   recipes.src = root_path+"/images/nav_main/recipes.gif";
   
   recipes_on = new Image(68,20);
   recipes_on.src = root_path+"/images/nav_main/recipes_on.gif";
   
   recipes_over = new Image(68,20);
   recipes_over.src = root_path+"/images/nav_main/recipes_over.gif";
   
   // END MAIN NAVIGATION PRELOADS

   if (js_pathparts[1] == "menus"){
   
      // BEGIN MENU NAVIGATION PRELOADS
      
      
      see_whats_new = new Image(170,18);
      see_whats_new.src = root_path+"/images/nav_sub/see_whats_new.gif";

      see_whats_new_on = new Image(170,18);
      see_whats_new_on.src = root_path+"/images/nav_sub/see_whats_new_on.gif";

      see_whats_new_over = new Image(170,18);
      see_whats_new_over.src = root_path+"/images/nav_sub/see_whats_new_over.gif";
      
      lunch = new Image(170,18);
      lunch.src = root_path+"/images/nav_sub/lunch.gif";
      
      lunch_on = new Image(170,18);
      lunch_on.src = root_path+"/images/nav_sub/lunch_on.gif";
      
      lunch_over = new Image(170,18);
      lunch_over.src = root_path+"/images/nav_sub/lunch_over.gif";
      
      dinner = new Image(170,18);
      dinner.src = root_path+"/images/nav_sub/dinner.gif";
      
      dinner_on = new Image(170,18);
      dinner_on.src = root_path+"/images/nav_sub/dinner_on.gif";
      
      dinner_over = new Image(170,18);
      dinner_over.src = root_path+"/images/nav_sub/dinner_over.gif";
	  
      freshfish = new Image(170,18);
      freshfish.src = root_path+"/images/nav_sub/freshfish.gif";
      
      freshfish_on = new Image(170,18);
      freshfish_on.src = root_path+"/images/nav_sub/freshfish_on.gif";
      
      freshfish_over = new Image(170,18);
      freshfish_over.src = root_path+"/images/nav_sub/FreshFish_over.gif";
	  
      dessert = new Image(170,18);
      dessert.src = root_path+"/images/nav_sub/dessert.gif";
      
      dessert_on = new Image(170,18);
      dessert_on.src = root_path+"/images/nav_sub/dessert_on.gif";
      
	  dessert_over = new Image(170,18);
      dessert_over.src = root_path+"/images/nav_sub/dessert_over.gif";
	  
      beverage = new Image(170,18);
      beverage.src = root_path+"/images/nav_sub/beverage.gif";
      
      beverage_on = new Image(170,18);
      beverage_on.src = root_path+"/images/nav_sub/beverage_on.gif";
      
      beverage_over = new Image(170,18);
      beverage_over.src = root_path+"/images/nav_sub/beverage_over.gif";
      
      kids = new Image(170,18);
      kids.src = root_path+"/images/nav_sub/kids.gif";
      
      kids_on = new Image(170,18);
      kids_on.src = root_path+"/images/nav_sub/kids_on.gif";
      
      kids_over = new Image(170,18);
      kids_over.src = root_path+"/images/nav_sub/kids_over.gif";
	  
      nutrition = new Image(170,18);
      nutrition.src = root_path+"/images/nav_sub/nutrition.gif";
      
      nutrition_on = new Image(170,18);
      nutrition_on.src = root_path+"/images/nav_sub/nutrition_on.gif";
      
      nutrition_over = new Image(170,18);
      nutrition_over.src = root_path+"/images/nav_sub/nutrition_over.gif";
	  
	  togo = new Image(170,18);
      togo.src = root_path+"/images/nav_sub/togo.gif";
	  
	  togo_over = new Image(170,18);
      togo_over.src = root_path+"/images/nav_sub/togo_over.gif";
      
      // END MENU NAVIGATION PRELOADS
   }

   if (js_pathparts[1] == "recipes"){

      // BEGIN RECIPE NAVIGATION PRELOADS
      
      appetizers = new Image(170,32);
      appetizers.src = root_path+"/images/nav_sub/appetizers.gif";
      
      appetizers_on = new Image(170,32);
      appetizers_on.src = root_path+"/images/nav_sub/appetizers_on.gif";
      
      appetizers_over = new Image(170,32);
      appetizers_over.src = root_path+"/images/nav_sub/appetizers_over.gif";
      
      sauces = new Image(170,18);
      sauces.src = root_path+"/images/nav_sub/sauces.gif";
      
      sauces_on = new Image(170,18);
      sauces_on.src = root_path+"/images/nav_sub/sauces_on.gif";
      
      sauces_over = new Image(170,18);
      sauces_over.src = root_path+"/images/nav_sub/sauces_over.gif";
      
      desserts = new Image(170,18);
      desserts.src = root_path+"/images/nav_sub/desserts.gif";
      
      desserts_on = new Image(170,18);
      desserts_on.src = root_path+"/images/nav_sub/desserts_on.gif";
      
      desserts_over = new Image(170,18);
      desserts_over.src = root_path+"/images/nav_sub/desserts_over.gif";
      
      main_dishes = new Image(170,18);
      main_dishes.src = root_path+"/images/nav_sub/main_dishes.gif";
      
      main_dishes_on = new Image(170,18);
      main_dishes_on.src = root_path+"/images/nav_sub/main_dishes_on.gif";
      
      main_dishes_over = new Image(170,18);
      main_dishes_over.src = root_path+"/images/nav_sub/main_dishes_over.gif";
      
      beverages = new Image(170,18);
      beverages.src = root_path+"/images/nav_sub/beverages.gif";
      
      beverages_on = new Image(170,18);
      beverages_on.src = root_path+"/images/nav_sub/beverages_on.gif";
      
      beverages_over = new Image(170,18);
      beverages_over.src = root_path+"/images/nav_sub/beverages_over.gif";
      
      jerk_cooking = new Image(170,18);
      jerk_cooking.src = root_path+"/images/nav_sub/jerk_cooking.gif";
      
      jerk_cooking_on = new Image(170,18);
      jerk_cooking_on.src = root_path+"/images/nav_sub/jerk_cooking_on.gif";
      
      jerk_cooking_over = new Image(170,18);
      jerk_cooking_over.src = root_path+"/images/nav_sub/jerk_cooking_over.gif";
      
      ingredients_ck = new Image(170,18);
      ingredients_ck.src = root_path+"/images/nav_sub/ingredients_ck.gif";
      
      ingredients_ck_on = new Image(170,18);
      ingredients_ck_on.src = root_path+"/images/nav_sub/ingredients_ck_on.gif";
      
      ingredients_ck_over = new Image(170,18);
      ingredients_ck_over.src = root_path+"/images/nav_sub/ingredients_ck_over.gif";
	  
      chefsblog_ck = new Image(170,18);
      chefsblog_ck.src = root_path+"/images/nav_sub/chefsblog_ck.gif";
      
      chefsblog_ck_on = new Image(170,18);
      chefsblog_ck_on.src = root_path+"/images/nav_sub/chefsblog_ck_on.gif";
      
      chefsblog_ck_over = new Image(170,18);
      chefsblog_ck_over.src = root_path+"/images/nav_sub/chefsblog_ck_over.gif";
	  
      recipes_ck = new Image(170,18);
      recipes_ck.src = root_path+"/images/nav_sub/recipes_ck.gif";
      
      recipes_ck_on = new Image(170,18);
      recipes_ck_on.src = root_path+"/images/nav_sub/recipes_ck_on.gif";
      
      recipes_ck_over = new Image(170,18);
      recipes_ck_over.src = root_path+"/images/nav_sub/recipes_ck_over.gif";
	  
      cuisine_ck = new Image(170,18);
      cuisine_ck.src = root_path+"/images/nav_sub/cuisine_ck.gif";
      
      cuisine_ck_on = new Image(170,18);
      cuisine_ck_on.src = root_path+"/images/nav_sub/cuisine_ck_on.gif";
      
      cuisine_ck_over = new Image(170,18);
      cuisine_ck_over.src = root_path+"/images/nav_sub/cuisine_ck_over.gif";
      // END RECIPE NAVIGATION PRELOADS
   }
   if (js_pathparts[1] == "locator"){

      // BEGIN LOCATOR NAVIGATION PRELOADS
      
      take_tour = new Image(170,18);
      take_tour.src = root_path+"/images/nav_sub/take_tour.gif";
      
      take_tour_on = new Image(170,18);
      take_tour_on.src = root_path+"/images/nav_sub/take_tour_on.gif";
      
      take_tour_over = new Image(170,18);
      take_tour_over.src = root_path+"/images/nav_sub/take_tour_over.gif";
      
      invite_friends = new Image(170,18);
      invite_friends.src = root_path+"/images/nav_sub/invite_friends.gif";
      
      invite_friends_on = new Image(170,18);
      invite_friends_on.src = root_path+"/images/nav_sub/invite_friends_on.gif";
      
      invite_friends_over = new Image(170,18);
      invite_friends_over.src = root_path+"/images/nav_sub/invite_friends_over.gif";
      
      call_ahead = new Image(170,18);
      call_ahead.src = root_path+"/images/nav_sub/call_ahead.gif";
      
      call_ahead_on = new Image(170,18);
      call_ahead_on.src = root_path+"/images/nav_sub/call_ahead_on.gif";
      
      call_ahead_over = new Image(170,18);
      call_ahead_over.src = root_path+"/images/nav_sub/call_ahead_over.gif";
      
      // END LOCATOR NAVIGATION PRELOADS
   }
}

function hiLite(imgDocID,imgObjName) {
   if( !document.images ) return;
   var sitenav_section = js_pathparts[1];
   if (sitenav_section == 'marketplace') sitenav_section = 'gift_card';
   if (location.host == "news.bahamabreeze.com" && location.href.indexOf('invite') == -1){
      if (imgDocID == 'insiders_button' && imgObjName != 'insiders_on') return;
   }
   else if (location.host.indexOf('researchhq') != -1){
      if (imgDocID == 'survey_button' && imgObjName != 'survey_on') return;
   }
   else{
      if ( (imgDocID == sitenav_section + '_button' || (imgDocID == js_pathparts[2] + '_button' && js_pathparts[2] != 'gift_card') )
           && imgObjName.indexOf('_on') == -1) return;
      if (imgDocID == js_pathparts[3] + '_button' && js_pathparts[3] != 'gift_card' && imgObjName.indexOf('_over') == -1) return;
   }
   if (document.images[imgDocID]) document.images[imgDocID].src = eval(imgObjName + ".src")
}

function initSiteNav() {
   var sitenav_section = js_pathparts[1];
   if (sitenav_section == 'marketplace') sitenav_section = 'gift_card';
   var section_button_name = sitenav_section+'_button';
   var section_button_on = sitenav_section+'_on';
   if (location.host == "news.bahamabreeze.com" && location.href.indexOf('invite') == -1){
      hiLite('insiders_button','insiders_on');
   }
   else if (location.host.indexOf('researchhq') != -1){
      hiLite('survey_button','survey_on');
   }
   else if (document.images[section_button_name] && section_button_name){
      hiLite(section_button_name,section_button_on);
   }
}

function initSubNav() {
   var subsection_button_name = js_pathparts[2]+'_button';
   var subsection_button_on = js_pathparts[2]+'_on';
   if (document.images[subsection_button_name] && subsection_button_on){
      hiLite(subsection_button_name,subsection_button_on);
   }
   var subsection_nav_div = js_pathparts[1]+'_'+js_pathparts[2];
   if (document.getElementById(subsection_nav_div)){
      document.getElementById(subsection_nav_div).style.display='block';
   }
   var page_link_div = js_pathparts[3];
   if (!page_link_div) page_link_div = js_pathparts[2];
   if (document.getElementById(page_link_div)){
      document.getElementById(page_link_div).className='bb_subnav_on';
   }
}

var cleared = 0;
function clearField(field){
   if (cleared != 1){   
      field.value = "";
      cleared=1;
   }
   else
      cleared = 0;
   } 

//begin popup

function loadPopup(url, xw, xh, name, scroll){


   // SPECIFY THE POPUP WINDOW NAME
   var win_popup_name = name;

   // SPECIFY URL OF MAIN POPUP WINDOW
   var win_popup_url = url;

   // SPECIFY THE WINDOW HEIGHT AND WIDTH
   var win_width = xw;
   var win_height = xh;

   // SPECIFY THE LOCATION OF THE TOP-LEFT CORNER OF THE WINDOW
   var win_left = (screen.width - win_width) / 2;
   var win_top = (screen.height - win_height) / 2;
   var popup_window = window.open(win_popup_url,win_popup_name,'width=' + win_width + ',height=' + win_height + ',top=' + win_top + ',left=' + win_left + ',directories=no,location=no,menubar=no,scrollbars=' + scroll + ',status=no,toolbar=no,resizable=no');
   popup_window.focus();
}

//end popup


//begin link back to main window

function linkBack(url){
   window.opener.location = url;
//  window.opener.focus();
   window.close();
}

//end link back to main window


//begin show and hide layers

var layer_ids = new Array();
layer_ids[0] = "email_page";

function showLayer (layer_id) {
var z = 0;

  for (z = 0; z < 1; z ++) {

    if (layer_id == layer_ids[z]) {
    document.getElementById(layer_ids[z]).style.display='block';
    }
    
    else {
    document.getElementById(layer_ids[z]).style.display='none';
    }
  }
}

function hideLayer (layer_id) {
var z = 0;

  for (z = 0; z < 1; z ++) {

    if (layer_id == layer_ids[z]) {
    document.getElementById(layer_ids[z]).style.display='none';
    }
    
  }
}

//end show and hide layers

//Sajax example
      // remote scripting library
      // (c) copyright 2005 modernmethod, inc
      var rs_debug_mode = false;
      var rs_obj = false;
      var rs_callback = false;
      var script_url = "/server_scripts/email_page.asp";
//      if (location.host == "bahama-breeze-dev.realbranding-test.com"){
//         script_url = "/server_scripts/email_page_demo.asp";
//      }
      
      function rs_debug(text) {
         if (rs_debug_mode)
            alert('RSD: ' + text)
      }
      
       function rs_init_object() {
          rs_debug('rs_init_object() called..')
          
          var A;
         try {
            A=new ActiveXObject('Msxml2.XMLHTTP');
         } catch (e) {
            try {
               A=new ActiveXObject('Microsoft.XMLHTTP');
            } catch (oc) {
               A=null;
            }
         }

         if(!A && typeof XMLHttpRequest != 'undefined')
            A = new XMLHttpRequest();
         if (!A) {
            rs_debug('Could not create connection object.');
            alert ('Could not create connection object');
          }
         return A;
      }
   // wrapper for send_to_friend
   function x_send_to_friend(){
      // count args; build URL
         var i, x, n;
         //var url = 'http://rl-us-beta-realbranding.info/dining/dinner/appetizers_alt.js.ss.asp?rs=send_to_friend', a = x_send_to_friend.arguments;
         url = script_url + '?rs=send_to_friend', a = x_send_to_friend.arguments;
         for (i = 0; i < a.length-1; i++) {
            url = url + '&rsargs[]=' + escape(a[i]);
            rs_debug('x_send_to_friend arg = &rsargs[]=' + escape(a[i]));
			}
         x = rs_init_object();
         x.open('GET', url, true);
         x.onreadystatechange = function() {
            if (x.readyState != 4)
               return;
            rs_debug('received ' + x.responseText);
            
            var status;
            var data;
            status = x.responseText.charAt(0);
            data = x.responseText;
            var pos = data.indexOf('[sajax_result________end]]');
             if (status == '-'){
               if(false){alert('Error: ' + data.substring(1,pos));}}
            else 
               a[a.length-1](data.substring(1,pos));
         }
         x.send(null);
         rs_debug('x_send_to_friend url = ' + url);
         rs_debug('x_send_to_friend waiting..');
      }

//	var z_stat_sent = "Email sent. Send  another or <a href=\"javascript:void(0);\" onclick=\"hideLayer('mail_friend');\">CLOSE THIS</a>"
	var z_stat_sent = "Email sent. Send  another?"
	var z_stat_error = "There was an error sending your email."
	var z_stat_process = "Sending... Please wait."

	function doSTFDone(z) {
    	document.getElementById("mail_friend_submit").style.visibility='visible';
		if (z == "true") {
			document.getElementById("mail_friend_status").innerHTML=z_stat_sent;
		} else {
			document.getElementById("mail_friend_status").innerHTML=z_stat_error + "<br>" + z;
		}			
	}
	
	function doSendToFriend() {
		document.getElementById("mail_friend_status").innerHTML=z_stat_process;
    	document.getElementById("mail_friend_submit").style.visibility='hidden';

		// get the folder name
		var to_name, to_email, to_message;
		
		from_name = document.getElementById("sender_name").value;
		from_email = document.getElementById("sender_email").value;
		to_name = document.getElementById("recipient_name").value;
		to_email = document.getElementById("recipient_email").value;
		to_message = document.getElementById("intro_text").value + "\n\n" + document.getElementById("message").value;
		x_send_to_friend(from_name, from_email, to_name, to_email, to_message, doSTFDone);
	}

//End Sajax example










