// JavaScript Document
//------------------------------------------------------->>> LANGUAGE JUMP MENU
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


  //-------CH BOX 1
  $('#ch_box').click(function(){  
	
  if($('#ch_box').get(0).checked){
  	$('div#second').slideDown(250);
  }
  else{
  	$('div#second').slideUp(200);
  }

  });
  
  //-------CH BOX 1
  $('#change_form_or_news_later').click(function(){  
	
  var counter_position = $('#counter_position').get(0);
  counter_po  	       = parseFloat(counter_position.innerHTML, 10);
	
	if(counter_po == 0){
		$('div#email_send_form').hide(250);
		$('div#schow_form').show(250);
		counter_po = 1;
		}else{
		$('div#email_send_form').show(250);
		$('div#schow_form').hide(250);
		counter_po = 0;	
			}

	counter_position.innerHTML  = counter_po;
  });

//------------------DROP DOWN STEP 2
$('.hidden_drop_down_toggler').live('click', function(){
    $(this).toggleClass('open');
    //$($(this).parents('table')[0]).find('.hidden_drop_down').slideToggle(150); OLD STYLE
    $($($($($(this).parents('div')[0]).parents('div')[0]).parents('div')[0]).parents('div')[0]).find('.hidden_drop_down').slideToggle(150);
});
//------------------DROP DOWN HOT DEALS
$('.fidden_drop_down_hot_deals').live('click', function(){
    $(this).toggleClass('open');
    $($(this).parents('table')[0]).find('.hidden_drop_down').slideToggle(150);
});

//-------------------------------------------------CONTACT MAP
$('.contacts_hidden_drop_down_1').live('click', function(){														 
    $('div#content_22_1').slideUp(0);
    $('div#content_22_2').slideDown(0);
    $('div#content_22_3').slideUp(0);
    $('div#content_22_4').slideUp(0);
    $('div#content_22_5').slideUp(0);
	$('div#content_22_6').slideUp(0);
       
    $('#contact_text_1').css("color", "#B1181C");
    $('#contact_text_2').css("color", "#2A9AC1");
    $('#contact_text_3').css("color", "#2A9AC1");
    $('#contact_text_4').css("color", "#2A9AC1");  
	$('#contact_text_5').css("color", "#2A9AC1"); 
});

$('.contacts_hidden_drop_down_2').live('click', function(){                                                         
    $('div#content_22_1').slideUp(0);
    $('div#content_22_2').slideUp(0);
    $('div#content_22_3').slideDown(0);
    $('div#content_22_4').slideUp(0);
    $('div#content_22_5').slideUp(0);
	$('div#content_22_6').slideUp(0);
    
    $('#contact_text_1').css("color", "#2A9AC1");
    $('#contact_text_2').css("color", "#B1181C");
    $('#contact_text_3').css("color", "#2A9AC1");
    $('#contact_text_4').css("color", "#2A9AC1"); 
	$('#contact_text_5').css("color", "#2A9AC1");
});

$('.contacts_hidden_drop_down_3').live('click', function(){                                                         
    $('div#content_22_1').slideUp(0);
    $('div#content_22_2').slideUp(0);
    $('div#content_22_3').slideUp(0);
    $('div#content_22_4').slideDown(0);
    $('div#content_22_5').slideUp(0);
	$('div#content_22_6').slideUp(0);
    
    $('#contact_text_1').css("color", "#2A9AC1");
    $('#contact_text_2').css("color", "#2A9AC1");
    $('#contact_text_3').css("color", "#B1181C");
    $('#contact_text_4').css("color", "#2A9AC1"); 
	$('#contact_text_5').css("color", "#2A9AC1"); 
});

$('.contacts_hidden_drop_down_4').live('click', function(){                                                         
    $('div#content_22_1').slideUp(0);
    $('div#content_22_2').slideUp(0);
    $('div#content_22_3').slideUp(0);
    $('div#content_22_4').slideUp(0);
    $('div#content_22_5').slideDown(0);
	$('div#content_22_6').slideUp(0);
    
    $('#contact_text_1').css("color", "#2A9AC1");
    $('#contact_text_2').css("color", "#2A9AC1");
    $('#contact_text_3').css("color", "#2A9AC1");
    $('#contact_text_4').css("color", "#B1181C");
	$('#contact_text_5').css("color", "#2A9AC1");
	
});

$('.contacts_hidden_drop_down_5').live('click', function(){                                                         
    $('div#content_22_1').slideUp(0);
    $('div#content_22_2').slideUp(0);
    $('div#content_22_3').slideUp(0);
    $('div#content_22_4').slideUp(0);
    $('div#content_22_5').slideUp(0);
	$('div#content_22_6').slideDown(0);
    
    $('#contact_text_1').css("color", "#2A9AC1");
    $('#contact_text_2').css("color", "#2A9AC1");
    $('#contact_text_3').css("color", "#2A9AC1");
    $('#contact_text_4').css("color", "#2A9AC1");
	$('#contact_text_5').css("color", "#B1181C");
	
});




//----------------------------------------------------END CONTACT MAP

function check_fields1(language) {
	
		if(language == 'bg'){
			text_1 = 'Моля въведете дата на наемане';
			text_2 = 'Моля веведете дата на връщане';	
		}		
		if(language == 'en'){
			text_1 = 'Please select Pick-up date';
			text_2 = 'Please select Return date';	
		}
		if(language == 'de'){
			text_1 = 'Bitte wählen Sie mietdatum';
			text_2 = 'Bitte wählen Sie rückgabedatum';	
		}
		if(language == 'ru'){
			text_1 = 'Пожалуйста, выберите дата получение';
			text_2 = 'Пожалуйста, выберите дата возврат';	
		}
		if(language == 'es'){
			text_1 = 'Por favor seleccione fecha alquiler';
			text_2 = 'Por favor seleccione fecha devolución';	
		}

        datefrom = document.getElementById('datefrom');
        dateto = document.getElementById('dateto');

        datefrom_hour = document.getElementById('datefrom_hour');
        dateto_hour = document.getElementById('dateto_hour');


        if(datefrom && datefrom.value.length == 0) {
                alert(text_1);
                return false;
        }

        if(dateto && dateto.value.length == 0) {
                alert(text_2);
                return false;
        }

        if(datefrom_hour && datefrom_hour.value == 0) {
                alert('Please select Pick-up time');
                return false;
        }

        if(dateto_hour && dateto_hour.value == 0) {
                alert('Please select Return return time');
                return false;
        }


        return true;
}
//-----------------
function popitup(url) {
	newwindow=window.open(url,'name','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,left=270,top=100,width=600,height=500');
	if (window.focus) {newwindow.focus()}
	return false;
}

function popitup_2_aaa(url) {
	newwindow=window.open(url,'name','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,left=270,top=100,width=600,height=500');
	if (window.focus) {newwindow.focus()}
	return false;
}

function popitup_3_aaa(url) {
    newwindow=window.open(url,'name','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,left=270,top=250,width=1000,height=710');
    if (window.focus) {newwindow.focus()}
    return false;
}

function popitup_4_aaa(url) {
    newwindow=window.open(url,'name','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,left=270,top=250,width=250,height=250');
    if (window.focus) {newwindow.focus()}
    return false;
}

//-----------------
function modify_search(a){
document.getElementById('modify_seach_button').innerHTML = '<input type="image" name="submit" src="/IMAGES/step_2/calculate/modify_search_2_'+a+'.png" />';	
}

function view_div(){
	$('#map_location').slideToggle(200);
	$('#map_text_1').slideToggle(200);
	$('#map_text_2').slideToggle(200);
}
function color_bg(value, counter){
	
	if(value == 1){
		color     = 'rgb(238, 238, 238)';
		color_now = $($('.car_1').parent('.background_car_down')[counter]).css('background-color');
		if(color != color_now){
			$($('.car_1').parent('.background_car_down')[counter]).css('background-color', color);	
		}
	}
   	if(value == 2){
		color = 'rgb(255, 255, 255)';
		$($('.car_1').parent('.background_car_down')[counter]).css('background-color', color);		
	}
	
}
/*
(function(){
  var timer = null, time = 2;
  
  function onTimeout(){
    location.reload();
  }

  timer = setTimeout(onTimeout, time * 400000);
})();
*/

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Steve Chipman | http://slayeroffice.com/ */

// constants to define the title of the alert and button text.
var ALERT_TITLE = "Oops!";
var ALERT_BUTTON_TEXT = "Close";

// over-ride the alert method only if this a newer browser.
// Older browser will see standard alerts





function createCustomAlert() {
  // shortcut reference to the document object
  d = document;

  // if the modalContainer object already exists in the DOM, bail out.
  if(d.getElementById("modalContainer")) return;

  // create the modalContainer div as a child of the BODY element
  mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
  mObj.id = "modalContainer";
   // make sure its as tall as it needs to be to overlay all the content on the page
  mObj.style.height = document.documentElement.scrollHeight + "px";
  
  mObj.onclick = function() { removeCustomAlert();return false; }

  // create the DIV that will be the alert 
  
  alertObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
  alertObj.id = "alertBox";
  // MSIE doesnt treat position:fixed correctly, so this compensates for positioning the alert
  if(d.all && !window.opera) alertObj.style.top = "50px";
  // center the alert box
  alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px";

  alertObj.innerHTML = txt;
  
  document.getElementById("alert_livechat").innerHTML=document.getElementById("void_id").innerHTML;
  
}

// removes the custom alert from the DOM
function removeCustomAlert() {
  document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
  document.getElementsByTagName("body")[0].removeChild(document.getElementById("alertBox"));
}

