var atsign = "@";
var virtual_domain = "bogayo"; 
var dotcom = ".com";

function popUp_window(URL, window_name, list_features)
{
   window.open(URL, window_name, list_features);
 }
 
 function redirect()
 {
	window.location.replace("http://www.bogayo.com");
 } 


function center_vertical(id_layer_1, id_layer_2)
{
   if (document.getElementById)
   {
	container_height = document.getElementById(id_layer_1).offsetHeight;
	main_content_height = document.getElementById(id_layer_2).offsetHeight;
	main_content_height = container_height/2 - main_content_height/2;
	document.getElementById(id_layer_2).style.top = main_content_height + 'px';

	return true
   }
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


//THIS FUNCTION DEALS SOLELY WITH THE CHANGING OF BACKGROUNDS
function main_background(index)
{
	 // alert("Hi there this is an error!!!");
  var bg = new Array();
  bg[0] = "url('images/homepage.jpg')";
  bg[1] = "url('images/aboutUs_homepage.jpg')";
  bg[2] = "url('images/food1a.jpg')";
  bg[3] = "url('images/bar_bg.jpg')";
  bg[4] = "url('images/contacts_bg.jpg')";
  bg[5] = "url('images/bogayo15f.jpg')";
  bg[6] = "url('images/lunchTime_menu.jpg')";
  /* update 09 07 */
  bg[7] = "url('images/update_09_07/bg_Cooking_hands.jpg')";

   for (var i=0; i<bg.length; i++)
   {
	  if (i==index)
	  {
	   //document.getElementById("aboutUs_content").style.display = "block";
	   document.getElementById("aboutUs_content").style.backgroundImage = bg[i];
	   break;
	  }
   }
}

//TOGGLES BETWEEN MAP & ADDRESS
function swap_location(swap)
{
	if(swap == 0)
	{
	document.getElementById("map").style.display = "block";	
	document.getElementById("map_address").style.display = "none";
	}
	else
	{
	document.getElementById("map").style.display = "none";	
	document.getElementById("map_address").style.display = "block";	
	}
}

//CHANGES THE LEFT MENUS / CONTENT
function display_layers(id)
{
	var layers = new Array('ethos', 'food_menu', 'drinks_menu', 'food', 'drinks', 'contact', 'lunchTime');
	
	for (var i=0; i<layers.length; i++)
	{
		if (i==id)
		{
			var show_layer = layers[id];
			document.getElementById(show_layer).style.display = "block";
		}
		else
		{
			var _layer = layers[i];
			document.getElementById(_layer).style.display = "none";
		}
	}	
}


//CHANGES THE IMAGES BETWEEN THE PARALLELS
function display_covers(img_index)
{
   var img_covers = new Array('img_map', 'img_homepage', 'restaurant_menu', 'bar_menu', 'mailing_list', 'lunch')	
   
   for (var i=0; i<img_covers.length; i++)
   {
	   if (i==img_index)
	   {
		   var display_cover = img_covers[img_index];
		  document.getElementById(display_cover).style.display = "block";
	   }
	   else
	   {
		 var img_layer = img_covers[i];
		 document.getElementById(img_layer).style.display = "none";
	   }
	 
   }
}

function mail_sent(layer)
{
   document.getElementById(layer).style.display = "block";	
}

//////////////////////////////////////////////////////////////////////////////////////

function display_details(id, menu)
{
	var layers = new Array('starters', 'tagine', 'couscous', 'brochettes', 'side_dishes', 'desserts','img_homepage', 'white_wines', 'champagne', 'rose', 'red_wine', 'bottle_beer', 'draught_beer', 'spirits', 'mixers', 'soft_drinks', 'img_map', 'restaurant_menu', 'bar_menu', 'bastilla', 'lunchtime_starters', 'lunchtime_main', 'whiskys', 'aperitifs', 'liqueurs', 'dessert_wines', 'coffees', 'lunch', 'tapas', 'shisha', 'breakfast', 'brunch', 'omelettes', 'lunch_sideOrder', 'lunch_desserts');

	for (var i=0; i<layers.length; i++)
	{
		if (i==id)
		{
			var show_layer = layers[id];
			var display_layer = document.getElementById(show_layer);
	        display_layer.style.display = "block";
			
			document.getElementById(menu).style.display = "block";
		}
		else
		{
			var _layer = layers[i];
			var display_layer = document.getElementById(_layer);
	        display_layer.style.display = "none";
		}
	}		
}

function rand(num) 
{
 return Math.floor(Math.random() * num) + 1;
}
	   
function navigation_bar()
{
   var navigation = "";
	   navigation += "<table id='tbl_navigation_bogayo' width='418' border='0' cellpadding='1' cellspacing='1'><tr>";
	   navigation += "<td><a href='javascript:main_background(1); display_layers(0);  display_covers(1);'>About Us</a></td>";	
	   navigation += "<td><a href='javascript:main_background(6); display_layers(6); display_covers(5);'>Lunch</a></td>";	 
	   navigation += "<td><a href='javascript:main_background(3); display_layers(1); display_covers(2);'>Dinner</a></td>"; 
	   navigation += "<td><a href='javascript:main_background(2); display_layers(2); display_covers(3);'>Drinks</a></td>";
	   navigation += "<td><a href='javascript:main_background(4); display_layers(5); display_covers(4);'>Contact</a></td>";
	   navigation += "</tr></table>";
	   document.write(navigation);
}  
																	
function contactForm()
{
	  var form = "";
	  /*
	      form += " <form action='https://sslrelay.com/bogayo.com/forms/forminfo.asp' method='post' id='frm_mailing_list' onsubmit='return validate(this);'>";
		  */
		  form += " <form action='https://sslrelay.com/bogayo.com/forms/forminfo.asp' method='post' id='frm_mailing_list' onsubmit='return validate(this);'>";
		  form += "<table id='tbl_mailing_list' border='0' cellpadding='3' cellspacing='3'>";
		  form += "<tbody><tr><td></td>";
		  form += "<td colspan='1' class='spacer' align='left' style='font-weight: bold; text-transform: uppercase; text-align: left; color: #C5A56B;'>Contact &amp; Information</td>";
		  form += "</tr><tr>";
		  form += "<td class='label'>enter e-mail</td>";
		  form += "<td><input type='text' name='email' id='email' /></td>";
		  form += "</tr><tr>";
		  form += "<td class='label'>confirm e-mail</td>";
		  form += "<td><input type='text' name='confirm_email' id='confirm_email' /></td>";
		  form += "</tr><tr>";
		  form += "<td class='label'>comment</td>";
		  form += "<td><textarea name='txt_comment' id='txt_comment' cols='17' rows='3'></textarea></td>";
		  form += "</tr><tr>";
		  form += "<td class='label'>please check</td>";
		  form += "<td align='left'><input type='checkbox' name='accept_terms' id='accept_terms' value='accept_terms' /></td>";
		  form += "</tr><tr><td>&nbsp;</td>";
		  form += "<td><input type='submit' name='Submit' value='Send Mail' /></td>";
		  form += "</tr></tbody></table></form>";
		  document.write(form);										
}

 function validate(the_form)
 {	   
     error_found = false 
	 
	
	 if(!valid_length(the_form.contactName.value, 3))
		error_message(the_form.contactName, "Please enter a contact name!"); 
	 
	  if(!valid_length(the_form.contactNumber.value, 3))
		error_message(the_form.contactNumber, "Please enter a contact telephone number!"); 
		
	  if(!the_form.accept_terms.checked)
          error_message(the_form.accept_terms, "Please check box to confirm addition to mailing list!!!");

	 
    
	/*
	 if(!regX_Email(the_form.email.value))
         error_message(the_form.email, "Please enter a valid e-mail address e.g. - me@you.com");
	 
	 //if(!compare_string(the_form.email.value, the_form.confirm_email.value))
	 
	 error_message(the_form.confirm_email, "Please confirm by re-entering your email address !!!");	  
	 */
	 
	 
	 
	 return !error_found
 }
 
 function valid_length(element_toCheck, req_length)
 {
   return (element_toCheck.length >= req_length);
 }
 
 function error_message(element_toHighlight, error_message)
 {
    //Abort if error found
	if(error_found) return
	
	window.alert(error_message);
	element_toHighlight.select();
	element_toHighlight.focus();
	
	error_found = true;
 }
  
 //COMPARISON (E-MAIL)
 function compare_string(string_1, string_2)
 {
  return (string_1 == string_2);
 } 
 
 // EMAIL VALIDATION - REG X
    function regX_Email(obj_email)
{
	// validate an e-mail address
	if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(obj_email))
	{
	  return false;
	}

	 return true;
}	

// USE THE FOLLOWING CODE TO LOAD STYLESHEET DYNAMICALLY 
		  /*
		  var i = Math.floor(Math.random() * 4)
		  document.write(i);
		  
		  var stylesheets = new Array(4)
		  stylesheets[0] = "../style/position_mid_july.css";
		  stylesheets[1] = "place1";
		  stylesheets[2] = "place2";
		  stylesheets[3] = "place3"; 
		  
		  var tell = stylesheets[i];
		  document.write(tell);
		  
		 
		  
		    if (document.createStyleSheet) 
			   {
			    document.createStyleSheet("../style/position_mid_july.css");
			   } 
			   else 
			   {
			       var test = "@import url(../style/position_mid_july.css);"
			       var dynamic_style = document.createElement("style");
			       dynamic_style.type = "text/css";
			       var stylesheet = document.createTextNode(test);
			       dynamic_style.appendChild(stylesheet);
			       document.getElementsByTagName("head")[0].appendChild(dynamic_style);
			   }
			   */

 
			   function show_img_txt(show, para)
			   {
			     var toView = document.getElementById(show);
				 toView.style.display = "block";
				 
				 var txt_color = document.getElementById(para);
				 txt_color.style.color = "blue";
			   }
			   
			   function hide_img_txt(show, para)
			   {
			     var toHide = document.getElementById(show, para);
				 toHide.style.display = "none";
				 
				 var txt_color = document.getElementById(para);
				 txt_color.style.color = "black";
			   }
			   
			   function display_img_txt(show, para)
			   {
			     var toHide = document.getElementById(show, para);
				 toHide.style.display = "block";
				 
				 var txt_color = document.getElementById(para);
				 txt_color.style.color = "red";
			   }
			   
			   function rand(num) 
			   {
                 return Math.floor(Math.random() * num) + 1;
				 }  
