$('#slideshow').cycle({
    speed:      2000,
    timeout:     4000,
    pager:      '#nav',
    pagerEvent: 'mouseover',
	pauseOnPagerHover: true
});
$(document).ready(function(){
$('#topMenu').css('visibility','visible');
$('#slideshow').css('visibility','visible');
///set default res date
setDefaultDates(0,1);
$('.ohLink').click(function() {
  $('#ohArea').show('fast');
});
$('.x').click(function() {
  $('#ohArea').hide('slow');
});
$('#langs').change(function() {
  $(window.location).attr('href', $(this).val());
});
$('.itemDetailLink').click(function() {
  var id = $(this).attr("title");
$('.conferenceItemDetail').hide();
$('#'+id).show(20);
});
});
// *************  CHECK IFRAME PARAMSFUNCTIONS *********
function checkIframeParams() {
 var paramForm = /articleID=\d+/;
 if ( document.location.href.match(paramForm)
   && document.getElementById('iframeAhiRes') ){
  var f = document.getElementById('iframeAhiRes');
  if ( !f.src.match(paramForm) ) {
   return false;
  }
  var newId = document.location.href.match(paramForm)[0];
  //alert(newId);
  f.src = f.src.replace(paramForm, newId);
 }
}
function checkIframeCategoryParams() {
 var paramForm = /categoryID=\d+/;
 if ( document.location.href.match(paramForm)
   && document.getElementById('iframeAhiRes') ){
  var f = document.getElementById('iframeAhiRes');
  //alert(f.src);
  if ( !f.src.match(paramForm) ) {
   return false;
  }
  var newId = document.location.href.match(paramForm)[0];
  f.src = f.src.replace(paramForm, newId);
 }
}
function checkIframeMonthParams() {
 var paramForm = /month=\d+/;
 if ( document.location.href.match(paramForm)
   && document.getElementById('iframeAhiRes') ){
  var f = document.getElementById('iframeAhiRes');
  if ( !f.src.match(paramForm) ) {
   return false;
  }
  var newId = document.location.href.match(paramForm)[0];
  //alert(newId);
  f.src = f.src.replace(paramForm, newId);
 }
}
function checkIframeOnlyMonthParams() {
 var paramForm = /onlyMonth=\d+/;
 if ( document.location.href.match(paramForm)
   && document.getElementById('iframeAhiRes') ){
  var f = document.getElementById('iframeAhiRes');
  if ( !f.src.match(paramForm) ) {
   return false;
  }
  var newId = document.location.href.match(paramForm)[0];
  //alert(newId);
  f.src = f.src.replace(paramForm, newId);
 }
}
function checkIframeYearParams() {
 var paramForm = /year=\d+/;
 if ( document.location.href.match(paramForm)
   && document.getElementById('iframeAhiRes') ){
  var f = document.getElementById('iframeAhiRes');
  if ( !f.src.match(paramForm) ) {
   return false;
  }
  var newId = document.location.href.match(paramForm)[0];
  //alert(newId);
  f.src = f.src.replace(paramForm, newId);
 }
}
function checkIframeDateFromParams() {
 var paramForm = /date_from=.+/;
 if ( document.location.href.match(paramForm)
   && document.getElementById('iframeAhiRes') ){
  var f = document.getElementById('iframeAhiRes');
  if ( !f.src.match(paramForm) ) {
   return false;
  }
  var newId = document.location.href.match(paramForm)[0];
  //alert(newId);
  f.src = f.src.replace(paramForm, newId);
 }
}
function checkIframeDateToParams() {
 var paramForm = /date_to=.+/;
 if ( document.location.href.match(paramForm)
   && document.getElementById('iframeAhiRes') ){
  var f = document.getElementById('iframeAhiRes');
  if ( !f.src.match(paramForm) ) {
   return false;
  }
  var newId = document.location.href.match(paramForm)[0];
  //alert(newId);
  f.src = f.src.replace(paramForm, newId);
 }
}
function checkIframeParamsShowPopup() {
 var paramForm = /showPopup=\w+/;
 if ( document.location.href.match(paramForm)
   && document.getElementById('iframeAhiRes') ){
  var f = document.getElementById('iframeAhiRes');
  if ( !f.src.match(paramForm) ) {
   return false;
  }
  var newId = document.location.href.match(paramForm)[0];
  //alert(newId);
  f.src = f.src.replace(paramForm, newId);
 }
}
function checkIframeParamsLang() {
 var paramForm = /lang=de/;
 if ( document.location.href.match(paramForm)
   && document.getElementById('iframeAhiRes') ){
  var f = document.getElementById('iframeAhiRes');
  //alert(f.src);
  if ( !f.src.match(paramForm) ) {
   return false;
  }
  var newId = document.location.href.match(paramForm)[0];
  //alert(newId);
  f.src = f.src.replace(paramForm, newId);
 }
}
function checkIframeParamsNumberOfRooms() {
 var paramForm = /numberOfRooms=\d+/;
 if ( document.location.href.match(paramForm)
   && document.getElementById('iframeAhiRes') ){
  var f = document.getElementById('iframeAhiRes');
  if ( !f.src.match(paramForm) ) {
   return false;
  }
  var newId = document.location.href.match(paramForm)[0];
  //alert(newId);
  f.src = f.src.replace(paramForm, newId);
 }
}
function checkIframeNewsletterUpdateParams() {
 var paramForm = /update=\d+/;
 if ( document.location.href.match(paramForm)
   && document.getElementById('iframeAhiRes') ){
  var f = document.getElementById('iframeAhiRes');
  if ( !f.src.match(paramForm) ) {
   return false;
  }
  var newId = document.location.href.match(paramForm)[0];
  //alert(newId);
  f.src = f.src.replace(paramForm, newId);
 }
}
function checkIframeNewsletterCustomerParams() {
 var paramForm = /customerID=\d+/;
 if ( document.location.href.match(paramForm)
   && document.getElementById('iframeAhiRes') ){
  var f = document.getElementById('iframeAhiRes');
  if ( !f.src.match(paramForm) ) {
   return false;
  }
  var newId = document.location.href.match(paramForm)[0];
  //alert(newId);
  f.src = f.src.replace(paramForm, newId);
 }
}
function checkIframeNewsletterID() {
 var paramForm = /newsletterID=\d+/;
 if ( document.location.href.match(paramForm)
   && document.getElementById('iframeAhiRes') ){
  var f = document.getElementById('iframeAhiRes');
  if ( !f.src.match(paramForm) ) {
   return false;
  }
  var newId = document.location.href.match(paramForm)[0];
  //alert(newId);
  f.src = f.src.replace(paramForm, newId);
 }
}
function checkIframeParamsQuestion() {
 var paramForm = /question=[a-zA-Z0-9\+\.\-_]+/;
 if ( document.location.href.match(paramForm)
   && document.getElementById('iframeAhiRes') ){
  var f = document.getElementById('iframeAhiRes');
  if ( !f.src.match(paramForm) ) {
   return false;
  }
  var newId = document.location.href.match(paramForm)[0];
  //alert(newId);
  f.src = f.src.replace(paramForm, newId);
 }
}
// *************  END CHECK IFRAME PARAMSFUNCTIONS *********
// --------------- START jscript pro rezervacni form v tele stranky (reservation & rates)
// rf 00 globalni promenna; bude v ni reference na FORM pro predavani mezi funkcemi
var globTheForm = false;
// rf 01
function adjustNumberOfPersons(thisElem) {
 globTheForm = getParentOf(thisElem);
 if ( !globTheForm ) {
  alerr('!globTheForm');
  return
 }
 globTheForm.elements["persons"].value = globTheForm.elements["single"].value*1 + globTheForm.elements["double"].value*2;
}
// rf 02
function checkCity(thisElem) {
 globTheForm = getParentOf(thisElem);
 if ( !globTheForm ) {
  alerr('!globTheForm');
  return
 }
 var hlaska = "";
 var alert1 = "select a city / wählen Sie eine Stadt";
 var alert2 = "Wrong arrival date\n";
 var alert3 = "Wrong departure date\n";
 if (globTheForm.elements["city"].value == "") {
  hlaska = hlaska + alert1;
 }
  var arr_year = globTheForm.elements["drpArrYear"].value;
 var arr_month = globTheForm.elements["drpArrMonth"].value;
 var arr_day = globTheForm.elements["drpArrDay"].value;
 var dep_year = globTheForm.elements["drpDepYear"].value;
 var dep_month = globTheForm.elements["drpDepMonth"].value;
 var dep_day = globTheForm.elements["drpDepDay"].value;
 var act_date = new Date();
 act_date = new Date(act_date.getFullYear(),act_date.getMonth(),act_date.getDate(), 00, 00, 00);
 var arr_date = new Date(arr_year,arr_month-1,arr_day, 00, 00, 00);
 var dep_date = new Date(dep_year,dep_month-1,dep_day, 00, 00, 00);
 if (act_date.valueOf() > arr_date.valueOf()) {
  hlaska = hlaska + alert2;
 }
 if (arr_date.valueOf() >= dep_date.valueOf()) {
  hlaska = hlaska + alert3;
 }
 if (hlaska != "") {
  alert(hlaska);
  return false;
 }
 globTheForm.setAttribute("target", "_blank");
 return true;
}
// rf 03 function checkHotelDates(thisElem) {
function checkHotelDates(thisElem) {
 globTheForm = getParentOf(thisElem);
 if ( !globTheForm ) {
  alert('!globTheForm');
  return
 }
 var hlaska = "";
 var alert2 = "Wrong arrival date\n";
 var alert3 = "Wrong departure date\n";
 var arr_year = globTheForm.elements["drpArrYear"].value;
 var arr_month = globTheForm.elements["drpArrMonth"].value;
 var arr_day = globTheForm.elements["drpArrDay"].value;
 var dep_year = globTheForm.elements["drpDepYear"].value;
 var dep_month = globTheForm.elements["drpDepMonth"].value;
 var dep_day = globTheForm.elements["drpDepDay"].value;
 var act_date = new Date();
 act_date = new Date(act_date.getFullYear(),act_date.getMonth(),act_date.getDate(), 00, 00, 00);
 var arr_date = new Date(arr_year,arr_month-1,arr_day, 00, 00, 00);
 var dep_date = new Date(dep_year,dep_month-1,dep_day, 00, 00, 00);
 if (act_date.valueOf() > arr_date.valueOf()) {
  hlaska = hlaska + alert2;
 }
 if (arr_date.valueOf() >= dep_date.valueOf()) {
  hlaska = hlaska + alert3;
 }
 if (hlaska != "") {
  alert(hlaska);
  return false;
 }
 globTheForm.setAttribute("target", "_blank");
 return true;
}
// validace rezervacniho formu
// rf 10
function checkRequestForm() {
 var f = document.forms["requestForm"];
 var f1 = /^[^0-9\-\ \/]+$/; // regular exp na cislo
 if(f.uName.value == ""){
  alert("Missing name");
  f.uName.select();
  f.uName.focus();
  return false;
 }
 if(f.surname.value == ""){
  alert("Missing surname");
  f.surname.select();
  f.surname.focus();
  return false;
 }
 if(f.Email.value == ""){
  alert("Missing email");
  f.Email.select();
  f.Email.focus();
  return false;
 } else if (f.Email.value.search(/[^@]+@.+\..+/) == -1){
  alert("Wrong email");
  f.Email.select();
  f.Email.focus();
  return false;
 }
 if(f.Phone.value == ""){
  alert("Missing phone");
  f.Phone.select();
  f.Phone.focus();
  return false;
 }
 if(f.captcha_response.value == ""){
  alert("Missing captcha");
  f.captcha_response.select();
  f.captcha_response.focus();
  return false;
 }
var form_url = $("#requestForm").attr("action");
    //alert("Before - action=" + form_url);       
    //changing the action to /$modules$/MailingModule
    $("#requestForm").attr("action","/$modules$/MailingModule");
    //alert("After - action = "+$("#requestForm").attr("action"));
    //submit the form
    //$("#requestForm").submit();
 return true;
}
// validace package formu
// rf 10
function checkPackageForm() {
 var f = document.forms["packageForm"];
 var f1 = /^[^0-9\-\ \/]+$/; // regular exp na cislo
 if(f.uName.value == ""){
  alert("Missing name");
  f.uName.select();
  f.uName.focus();
  return false;
 }
 if(f.surname.value == ""){
  alert("Missing surname");
  f.surname.select();
  f.surname.focus();
  return false;
 }
 if(f.Email.value == ""){
  alert("Missing email");
  f.Email.select();
  f.Email.focus();
  return false;
 } else if (f.Email.value.search(/[^@]+@.+\..+/) == -1){
  alert("Wrong email");
  f.Email.select();
  f.Email.focus();
  return false;
 }
 if(f.Phone.value == ""){
  alert("Missing phone");
  f.Phone.select();
  f.Phone.focus();
  return false;
 }
 if(f.DateFrom.value == ""){
  alert("Missing date from");
  f.DateFrom.select();
  f.DateFrom.focus();
  return false;
 }
 if(f.DateTo.value == ""){
  alert("Missing date to");
  f.DateTo.select();
  f.DateTo.focus();
  return false;
 }
 if(f.Delegates.value == ""){
  alert("Missing number of guests");
  f.Delegates.select();
  f.Delegates.focus();
  return false;
 }
 if(f.Numbers.value == ""){
  alert("Missing number of rooms");
  f.Numbers.select();
  f.Numbers.focus();
  return false;
 }
 if(f.captcha_response.value == ""){
  alert("Missing captcha");
  f.captcha_response.select();
  f.captcha_response.focus();
  return false;
 }
 return true;
}
// validace package formu
// rf 10
function checkGastebuchForm() {
 var f = document.forms["gastebuchForm"];
 var f1 = /^[^0-9\-\ \/]+$/; // regular exp na cislo
if(f.Company.value == ""){
  alert("Missing company");
  f.Company.select();
  f.Company.focus();
  return false;
 } 
if(f.uName.value == ""){
  alert("Missing name");
  f.uName.select();
  f.uName.focus();
  return false;
 }
 if(f.surname.value == ""){
  alert("Missing surname");
  f.surname.select();
  f.surname.focus();
  return false;
 }
 if(f.Email.value == ""){
  alert("Missing email");
  f.Email.select();
  f.Email.focus();
  return false;
 } else if (f.Email.value.search(/[^@]+@.+\..+/) == -1){
  alert("Wrong email");
  f.Email.select();
  f.Email.focus();
  return false;
 }
 if(f.Phone.value == ""){
  alert("Missing phone");
  f.Phone.select();
  f.Phone.focus();
  return false;
 }
 if(f.Comment.value == ""){
  alert("Missing comment");
  f.Comment.select();
  f.Comment.focus();
  return false;
 }
 if(f.captcha_response.value == ""){
  alert("Missing captcha");
  f.captcha_response.select();
  f.captcha_response.focus();
  return false;
 }
 return true;
}
var startDepartureDay = 1;
 var msecsInADay = 86400000;
// *************  SET DEFAULT DATES FUNCTIONS *********
// changeDepDay - true / false ;
// startDay - add days to a now date
// startDepDay - add days to arrDay
function setDepDate(changeDepDay)
{
  if(document.getElementById("drpArrYear"))
  {
   var drpArrYear     = document.getElementById("drpArrYear");
   var drpArrMonth    = document.getElementById("drpArrMonth");
   var drpArrDay      = document.getElementById("drpArrDay");
   var drpDepYear     = document.getElementById("drpDepYear");
   var drpDepMonth    = document.getElementById("drpDepMonth");
   var drpDepDay      = document.getElementById("drpDepDay"); 
   var arrivalDate = new Date(drpArrYear.value,drpArrMonth.value-1,drpArrDay.value, 00, 00, 00);
   var arrivalDatePlusX = new Date(arrivalDate.getTime() + (startDepartureDay*msecsInADay));
   //arrivalDatePlusX.setDate(arrivalDate.getTime()+(startDepartureDay*msecsInADay));
   var departureDate = new Date(arrivalDatePlusX.getFullYear(),arrivalDatePlusX.getMonth(),arrivalDatePlusX.getDate(), 00, 00, 00);
   //alert(arrivalDate+departureDate);
   //if I don't want to influence dep day
   if(!changeDepDay)
   {
      departureDate = new Date(drpArrYear.value,drpArrMonth.value-1,drpDepDay.value, 00, 00, 00);
   }  
   //check of dates in past
   if(arrivalDate.getMonth() < new Date().getMonth() && arrivalDate.getYear() == new Date().getYear())
   {
      arrivalDate = new Date(arrivalDate.getFullYear()+1,drpArrMonth.value-1,drpArrDay.value, 00, 00, 00);
      //alert(arrivalDate);
      departureDate = new Date(arrivalDate.getFullYear(),drpArrMonth.value-1,drpDepDay.value, 00, 00, 00);
   }  
   //alert(startDepartureDay);
    // set proper number of days for selected month
   setDaysInMonth(arrivalDate.getMonth(),arrivalDate.getFullYear(),drpArrDay, false);
   setDaysInMonth(departureDate.getMonth(),departureDate.getFullYear(),drpDepDay, false);   
   drpArrDay.value    = arrivalDate.getDate();
   drpArrMonth.value  = arrivalDate.getMonth()+1;
   drpArrYear.value   = arrivalDate.getFullYear();
   drpDepDay.value    = departureDate.getDate();
   drpDepMonth.value  = departureDate.getMonth()+1;
   drpDepYear.value   = departureDate.getFullYear(); 
  }  
}
// set proper number of days for selected month
function setDaysInMonth(the_month, the_year, dayObject, keepSelectedValue)
{
   var day_in_month = 31;
   if ( the_month == 3 ||
        the_month == 5 ||
        the_month == 8 ||
        the_month == 10 ) {
    day_in_month=30;
   }
   if(the_month == 1) {
    day_in_month=28;
    if( ( (the_year % 4 == 0) && (the_year % 100 != 0) ) ||
        (the_year % 400 == 0) ) {
     day_in_month=29;
    }
   }
   var selValue = 1;
   if(keepSelectedValue)
   {
    selValue = dayObject.value;
   }
 //delete options
if(dayObject)
{
 for(var i=0; i<dayObject.options.length; i++) {
  dayObject.options[i]=null;
 }
}
 //set options by date
 for( var i=1; i<=day_in_month; i++ ) {
   dayObject.options[i-1] = new Option((i),(i),false);
 }
  if(keepSelectedValue)
   {
    dayObject.value = selValue;
   }  
}
// set default values to options
// startArrDay - setup start day : now + startArrDay
// startDepDay - setup dep day : arrDay + startDepDay
function setDefaultDates(startArrDay, startDepDay)
{
 if(document.getElementById("drpArrYear"))
  {
  startDepartureDay   = startDepDay;
   var drpArrYear     = document.getElementById("drpArrYear");
   var drpArrMonth    = document.getElementById("drpArrMonth");
   var drpArrDay      = document.getElementById("drpArrDay");
   var drpDepYear     = document.getElementById("drpDepYear");
   var drpDepMonth    = document.getElementById("drpDepMonth");
   var drpDepDay      = document.getElementById("drpDepDay");
   var today = new Date();   
	 var arrDate = new Date(today.getTime() + (startArrDay*msecsInADay));
   //arrDate.setDate(today.getDate()+startArrDay);
   var depDate = new Date(arrDate.getTime() + (startDepDay*msecsInADay));
   //depDate.setDate(arrDate.getDate()+startDepDay);       
   // set proper number of days for selected month
   setDaysInMonth(arrDate.getMonth(),arrDate.getFullYear(),drpArrDay, false);
   setDaysInMonth(depDate.getMonth(),depDate.getFullYear(),drpDepDay, false);
   //set actual years
   setYear(drpArrYear);
   setYear(drpDepYear);
   drpArrDay.value    = arrDate.getDate();
   drpArrMonth.value  = arrDate.getMonth()+1;
   drpArrYear.value   = arrDate.getFullYear();
   drpDepDay.value    = depDate.getDate();
   drpDepMonth.value  = depDate.getMonth()+1;
   drpDepYear.value   = depDate.getFullYear();
}
}
// set available years
function setYear(yearObject)
{
  //delete options
   for(var i=0; i<yearObject.options.length; i++) {
    yearObject.options[i]=null;
   }
   var thisYear = new Date().getFullYear();
   var numberOfYearsDisp = 2;
   //set options by date
   for( var j=0; j<= numberOfYearsDisp; j++ ) {
     yearObject.options[j] = new Option((thisYear+j),(thisYear+j),false);
   }
}
//************* END SET DEFAULT DATES FUNCTIONS ******
// addEvent( object, eventType,function )
// by John Resig
function cldr_addEvent( obj, type, fn ) {
 if ( obj.attachEvent ) {
  obj['e'+type+fn] = fn;
  obj[type+fn] =function(){obj['e'+type+fn]( window.event );}
  obj.attachEvent( 'on'+type, obj[type+fn] );
 } else {
  obj.addEventListener( type, fn, false );
 }
}
function cldr_removeEvent( obj, type, fn ) {
 if ( obj.detachEvent ) {
  obj.detachEvent( 'on'+type, obj[type+fn] );
  obj[type+fn] = null;
 } else {
  obj.removeEventListener( type, fn, false );
 }
}
//
// swapDisplay()
//
function swapDisplay() {
 values = ['none','block']
 for ( var i = 0; i < arguments.length; i++ ) {
  el = getObject(arguments[i]);
  if ( el ) {
   elStyle = getStyle(el,'display');
   if ( elStyle) {
    if ( elStyle == values[0] ) {
     el.style.display = values[1];
    }
    else if (elStyle == values[1]) {
     el.style.display = values[0];
    }
   }
  }
 }
}
//
// getObject(param)
//
function getObject(param) {
 var rtrn = false;
 if ( typeof(param) == 'object' ) {
  rtrn = param;
 }
 else if ( typeof(param) == 'string' ) {
  if ( document.getElementById(param) ) {
   rtrn = document.getElementById(param);
  }
  else if ( document.getElementsByTagName(param)[0] ) {
   rtrn = document.getElementsByTagName(param)[0];
  }
 }
 return rtrn
}
//
// getStyle(oElm, strCssRule)
// by Robert Nyman
// http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/
//
function getStyle(oElm, strCssRule){
 var strValue = "";
 if(document.defaultView && document.defaultView.getComputedStyle){
  strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
 }
 else if(oElm.currentStyle){
  strCssRule = strCssRule.replace(/-(w)/g, function (strMatch, p1){
   return p1.toUpperCase();
  });
  strValue = oElm.currentStyle[strCssRule];
 }
 return strValue;
}
function readCookie(name)
{
  var ca = document.cookie.split(';');
  var nameEQ = name + "=";
  for(var i=0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
  return null;
}
