$(document).ready(function(){
						  $('#header_search_form #query').keyup(function() {
														
													 $('.ac_results').css('dispaly','block');
													 $('.search_text_wrapper_inputbox').css('dispaly','block');
													 var len = $('#query').val();
														
													if((len.length)>=2 && $('#mainpageresult').length<1)
													 {
													  $('.search_text_wrapper_inputbox').append('<div class="ac_results" id="mainpageresult" style="padding-left:15px; width:auto;" ><img height="15" width="128" id="notam_loader" style="margin:2px;" src="/images/ajax-loader.gif"/></div>');						
													 }
													 if((len.length)>=15 || (len.length)<2)
													 {
														 	$('#mainpageresult').remove();
													 }
													 
													 });
											 
											 
								$('#ev_homepage').click(function(){
																   	$('#mainpageresult').remove();
																   });			
						   });

function clearField(id, value) {
  var el = document.getElementById(id);
  if (el.value == value) {
    el.value = '';
  }
}
 
function checkFieldValue(id, value) {
  var el = document.getElementById(id);
  if (el.value.length == 0 || el.value == null) {
    el.value = value;
  }
}

function checkFieldValue_tiny(ed, value) {
  var count=(ed.activeEditor.getContent()).replace(/(<([^>]+)>)/ig,"");
 
 if(count.length == 0)
  {
 	
 	ed.activeEditor.setContent(value);
  }
  
 
}

function slideShowHide(details_id, summary_id) {
  $(summary_id).slideUp();
  $(details_id).slideDown();
}
 
function toggleImage(details_id, image_id) {
  if ($(image_id).attr('alt') == 'Search_small_arrow_right') {
    $(details_id).slideDown();
    $(image_id).attr('src', $(image_id).attr('src').replace('right', 'down'));
    $(image_id).attr('alt', 'Search_small_arrow_down');
  } else {
    $(details_id).slideUp();
    $(image_id).attr('src', $(image_id).attr('src').replace('down', 'right'));
    $(image_id).attr('alt', 'Search_small_arrow_right');
  }
}
 
function toggleImageExtraFilters(details_id, image_id) {
  if ($(image_id).attr('alt') == 'Search_small_arrow_right') {
    if (details_id == '#equipment_content') {
      $('#environment_content').slideUp();
      $('#environment_arrow').attr('src', $('#environment_arrow').attr('src').replace('down', 'right'));
      $('#environment_arrow').attr('alt', 'Search_small_arrow_down');

      $('#area_content').slideUp();
      $('#area_arrow').attr('src', $('#area_arrow').attr('src').replace('down', 'right'));
      $('#area_arrow').attr('alt', 'Search_small_arrow_down');
    } else if (details_id == '#environment_content') {
      $('#equipment_content').slideUp();
      $('#equipment_arrow').attr('src', $('#equipment_arrow').attr('src').replace('down', 'right'));
      $('#equipment_arrow').attr('alt', 'Search_small_arrow_down');

      $('#area_content').slideUp();
      $('#area_arrow').attr('src', $('#area_arrow').attr('src').replace('down', 'right'));
      $('#area_arrow').attr('alt', 'Search_small_arrow_down');
    } else if (details_id == '#area_content') {
      $('#equipment_content').slideUp();
      $('#equipment_arrow').attr('src', $('#equipment_arrow').attr('src').replace('down', 'right'));
      $('#equipment_arrow').attr('alt', 'Search_small_arrow_down');

      $('#environment_content').slideUp();
      $('#environment_arrow').attr('src', $('#environment_arrow').attr('src').replace('down', 'right'));
      $('#environment_arrow').attr('alt', 'Search_small_arrow_down');
    }
     
    $(details_id).slideDown();
    $(image_id).attr('src', $(image_id).attr('src').replace('right', 'down'));
    $(image_id).attr('alt', 'Search_small_arrow_down');
  } else {
    $(details_id).slideUp();
    $(image_id).attr('src', $(image_id).attr('src').replace('down', 'right'));
    $(image_id).attr('alt', 'Search_small_arrow_right');
  }
}
 
function toggleAccordionImage(image_id, max, text_id) {
  if (!text_id) {
    text_id = 'space_';
  }
  for (var i=1; i<=max; i++) {
    $('#'+text_id+i).attr('src', $('#'+text_id+i).attr('src').replace('down', 'right'));
    $('#'+text_id+i).attr('alt', 'Search_right_arrow');  
  }
  $(image_id).attr('src', $(image_id).attr('src').replace('right', 'down'));
  $(image_id).attr('alt', 'Search_down_arrow');
}

function accordion(id, max) {
  for(var i=1; i<=max; i++) {
    if (i != id) {
      $('#job'+i).slideUp();
      $('#job_heading' + i + ' td').css({'font-weight': 'normal'});
      $('#job_heading' + i + ' td.last a').css({'font-weight': 'bold'});
      $('#job_heading' + i + ' td').css({'text-decoration': 'none'});
    }
  }
  $('#job'+id).slideToggle();
  if ($('#job_heading'+id + ' td.last a').css('font-weight') == 'bold') {
    $('#job_heading' + id + ' td').css({'font-weight': 'bold'});
    $('#job_heading' + id + ' td.last a').css({'font-weight': 'normal'});
    $('#job_heading' + id + ' td').css({'text-decoration': 'underline'});
  } else {
    $('#job_heading' + id + ' td').css({'font-weight': 'normal'});
    $('#job_heading' + id + ' td.last a').css({'font-weight': 'bold'});
    $('#job_heading' + id + ' td').css({'text-decoration': 'none'});
  }
}

function accordionRoom(id, max) {
  for(var i=1; i<=max; i++) {
    if (i != id) {
      $('#room_details_'+i).slideUp();
      $('#arrow_'+i).attr('src', $('#arrow_'+i).attr('src').replace('down', 'right'));
      $('#arrow_'+i).attr('alt', 'Search_right_arrow');
    }
  }
  $('#room_details_'+id).slideToggle();
  if ($('#arrow_'+id).attr('alt') == 'Search_right_arrow') {
    $('#arrow_'+id).attr('src', $('#arrow_'+id).attr('src').replace('right', 'down'));
    $('#arrow_'+id).attr('alt', 'Search_down_arrow');
  } else {
    $('#arrow_'+id).attr('src', $('#arrow_'+id).attr('src').replace('down', 'right'));
    $('#arrow_'+id).attr('alt', 'Search_right_arrow');
  }
}
 
function displayStar(image_id, max) {
  for (var i=1; i<=max; i++) {
    if (i <= image_id) {
      $('#star_'+ i).attr('src', $('#star_'+ i).attr('src').replace('off', 'on'));
      $('#star_'+ i).attr('alt', 'Search_big_star_on');
    } else {
      $('#star_'+ i).attr('src', $('#star_'+ i).attr('src').replace('on', 'off'));
      $('#star_'+ i).attr('alt', 'Search_big_star_off');
    }
  }
  $('#max_stars').val(image_id);
}

function submitFilters() {
  $('#frmFilters').submit();
}
 
function showImage(image, room_id) {
  $('#bigImage_'+room_id).attr('src', image);
}

function saveFavoritesList(id) {
  if(!$.cookie('favoritesList')) {
    $.cookie('favoritesList', id, { expires: 7, path: '/' } );
    return;
  }
  var space_data = $.cookie('favoritesList').split("^");
  var isAlreadySaved = false;
  for(var i=0; i < space_data.length; i++) {
    if(space_data[i] == id){
      isAlreadySaved = true;
      break;
    }
  }
  if(!isAlreadySaved) $.cookie('favoritesList' , $.cookie('favoritesList') + "^" + id, { expires: 7, path: '/' } );
  if( $.cookie('favoritesList') ) {
    var space_data = $.cookie('favoritesList').split("^");
    $('#favorites_count').text(space_data.length);
  }
}

function getFavoritesList() {
  var ret = new Array();
  if( $.cookie('favoritesList') ) {
    $('#favorites').val($.cookie('favoritesList'));
  }
}

function countFavorites() {
  if( $.cookie('favoritesList') ) {
    var space_data = $.cookie('favoritesList').split("^");
    $('#favorites_count').text(space_data.length);
  } else {
    $('#favorites_count').text(0);
  }
}

$.fn.clearForm = function() {
  return this.each(function() {
  var type = this.type, tag = this.tagName.toLowerCase();
  if (tag == 'form')
    return $(':input',this).clearForm();
  if (type == 'text' || type == 'password' || tag == 'textarea' || (type == 'hidden' && this.name != 'query')) {
    this.value = '';
  }
  else if (type == 'checkbox' || type == 'radio') {
    this.checked = false;
  }
  else if (tag == 'select') {
    this.selectedIndex = -1;
  }
  });
};
 
function togglePlans(level, level_id, max_level_elements) {
  if ($('#arrow_'+level+level_id).attr('alt') == 'Search_right_arrow') {
    $('#arrow_'+level+level_id).attr('src', $('#arrow_'+level+level_id).attr('src').replace('right', 'down'));
    $('#arrow_'+level+level_id).attr('alt', 'Search_down_arrow');
  } else {
    $('#arrow_'+level+level_id).attr('src', $('#arrow_'+level+level_id).attr('src').replace('down', 'right'));
    $('#arrow_'+level+level_id).attr('alt', 'Search_right_arrow');
  }
  for (var i = 1; i <= max_level_elements; i++) {
    if (i != level_id) {
      $('#'+level+i).slideUp();
      $('#arrow_'+level+i).attr('src', $('#arrow_'+level+i).attr('src').replace('down', 'right'));
      $('#arrow_'+level+i).attr('alt', 'Search_right_arrow');
    }
  }
  $('#'+level+level_id).slideToggle();
}
 
function changeCurrency(newCurrency) {
  $('#currency').val(newCurrency);
  $('#min_price').val('');
  $('#max_price').val('');
  submitFilters();
}

function changeMeasureUnits(newUnits) {
  $('#units').val(newUnits);
  submitFilters();
}

function changeUnits() {
  $('#details_form').submit();
}

function setType(id, layout_name) {
  $('#type_layout').val(id);
  $('#layout_class').val(layout_name);
  submitFilters();
}

function updateCapacity(max_capacity) {
  if ($('#max_peoples').val() > max_capacity) {
    $('#max_peoples').val(max_capacity);
  }
  submitFilters();
}

function newToggleAcc(id)
{
	if($(id).children('ul').css('display')=='none')
	$(id).children('ul').show();
	else
	$(id).children('ul').hide();
}
function onlyImageToggle(image_id, max, text_id) {
   if ($(image_id).attr('alt') == 'Search_right_arrow') {
    $(image_id).attr('src', $(image_id).attr('src').replace('right', 'down'));
    $(image_id).attr('alt', 'Search_down_arrow');
  } else {
    $(image_id).attr('src', $(image_id).attr('src').replace('down', 'right'));
    $(image_id).attr('alt', 'Search_right_arrow');
  }
}

function toggleForMeasure(id)
{
	if($(id).children('ul').css('display')=='none')
	{
		$(id).children('ul').show();
		$(id).children('ul').css({"height":"auto"});
	}
	else
	$(id).children('ul').hide();
}

/*
* This function changes the style for 'Description' field(Spaces)
* @author:shripadj@siddhatech.com
*/
function change_spanstyle()
{
	$('#description').find('span').css({"font-family":"inherit", "color":"#414141"});
}
