// kolp **** [browser sniffer] 
// 9. 11. 2003 
function browser() {
  this.ns = document.layers ? true : false;
  this.op = (navigator.userAgent.indexOf('Opera') == 0) ? true : false
  this.ie = (document.all && !this.op) ? true:false;
  this.mz = (document.getElementById && !this.ie && !this.op) ? true : false;
}
browser = new browser;

// pop-up function

var newWin = null;

function closeWin() {
	if (newWin != null) {
		if(!newWin.closed) newWin.close();
	}
}

function openWin(strURL,strType,strHeight,strWidth) {
  closeWin();
  var strOptions="";
  if (strType=="console") strOptions="resizable,scrollbars,height="+strHeight+",width="+strWidth;
  if (strType=="fixed") strOptions="resizable,status,height="+strHeight+",width="+strWidth;
  if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
  newWin = window.open(strURL, 'newWin', strOptions);
  newWin.focus();
  /*newWi.onclose = function() { alert("huhu"); }*/
  /*newWin.onclick = function() { newWin.close(); };*/
}

// Example of GOOD link
// <a href="XXXX.html" onclick="openWin(this.href,'console',400,200);return false;">XXXX</a>

/* Reference */

function initArray() {
  this.length = initArray.arguments.length;
  for (var i = 0; i < this.length; i++)
  this[i+1] = initArray.arguments[i];
}

/*
hlaska = new initArray(
'Flash kartu z digitálního fotoaparátu spadlého do toalety <br /><br /><img src="images/stories/toilet.jpg"/>',
'data z CD, které ohryzal pes <br /><br /><img src="images/stories/dog.jpg"/>',
'Flash PenDrive přejetý autem <br /><br /><img src="images/stories/car.jpg"/>',
'disk z notebooku politého Whisky <br /><br /><img src="images/stories/whisky.jpg"/>',
'disk z notebooku, který spadl z pračky při odstřeďování  <br /><br /><img src="images/stories/wash.jpg"/>',
'disk z notebooku ukrytého před zloději do trouby bez vědomí manželky, která druhý den chtěla péct  <br /><br /><img src="images/stories/cooker.jpg"/>',
'disk po pádu ze schodů <br /><br /><img src="images/stories/stairs.jpg"/>',
'disk utopený v bazénu rodinného domku &mdash; úspěšná záchrana dat u disků zasažených vodou závisí hlavně na rychlém přinesení k opravě <br /><br /><img src="images/stories/pool.jpg"/>',
'disk z notebooku, který prošel požárem <br /><br /><img src="images/stories/fire.jpg"/>'
);
*/

wedding = new initArray(
'<blockquote>&bdquo;The location is marvellous, a fairy tale setting.&ldquo;</blockquote><blockquote>&bdquo;The service by the Czech Travel Centre staff, from first enquiry right through the big day was impeccable.&ldquo;</blockquote><blockquote>&bdquo;We would recommend the experience to anyone.&ldquo;</blockquote><div class="sign">Mr &amp; Mrs Carter</div><div class="line"><img src="/images/ornaments/line-02.gif" alt="----" /></div><p>  <a href="/images/reference/weddings-reference-01.jpg" rel="lightbox"><img alt="Weddings in Prague" src="/images/reference/_weddings-reference-01.jpg" /></a>  &nbsp;&nbsp;  <a href="/images/reference/weddings-reference-02.jpg" rel="lightbox"><img alt="Weddings in Prague" src="/images/reference/_weddings-reference-02.jpg" /></a></p>',
'<blockquote>We made a decision to get married during our holiday in Prague a couple of months before our trip. We did our homework and realised that we needed some professional, reliable help and found that Czech travel centre offered a great service at a good price. They immediately impressed by responding quickly to my e-mail and were incredibly helpful throughout. They were very patient when we hit problems with our paperwork and - obviously - had a thorough understanding of the UK and Czech systems. Allow a morning to go through the legalities in Prague (or wherever). The day itself was wonderful - a wedding in the old town hall, the ceremony conducted by a councillor of old Prague. An amazing experience. Thank you.</blockquote><div class="sign">Nicholas Bell</div>'
);


function randN() {
  nahoda = Math.ceil(Math.random() * (wedding.length));
  return nahoda;
}

var randNum = randN();
var maxNum = wedding.length;

function storyWedding(where) {
  p=document.getElementById(where);
  p.innerHTML = wedding[randNum];
  if(randNum == maxNum) randNum = 1; 
  else randNum++;
}



/* ... end of Reference */


function showImg(imgId,value) {
  img = document.getElementById(imgId);
  img.src = "/images/mini/"+value+".gif";
  // if(img.src != '') 
  // else img.src = "/images/_blank.gif";
}

function showHide(elId,cb,formId) {
  tr = document.getElementById(elId+"Tr");
  inp = document.getElementById(elId+""+formId);
  img = document.getElementById(elId+"Img");
  if (cb.checked) {
    if(browser.ie) tr.style.display = "block";
    else tr.style.display = "table-row";
  } else  {
    tr.style.display = "none";
    inp.value = "blank";
    img.src = "/images/mini/blank.gif"
  }
}

function showHideElement(element,displayType) {
  el = document.getElementById(element);
	if (el.style.display == displayType) {
	  el.style.display = "none";
	} else {
	  el.style.display = displayType;
	}
}

function validate(form) {
  var invalid = false; 
  var desc = 'There are fileds witch need correction before sending!\n------------------------------------------------------------------------------------\n';
  if (form.from.value == '') { invalid = true; desc += '- date is required\n';}
  if (form.name.value == '') { invalid = true; desc += '- name is required\n';}
  if (form.phone.value == '') { invalid = true; desc += '- phone is required\n';}
  /*if (! form.phone.value.match('[0-9]')) { invalid = true; desc += '- please enter a valid phone number\n';}*/
  if (form.email.value == '') { invalid = true; desc += '- email is required\n';}
  if (! form.email.value.match('^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$')) { invalid = true; desc += '- please enter a valid email address\n';}
  if (invalid) {
    alert(desc);
    return false
  }
}

// COOKIE FUNCTIONS

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function eraseCookie(name) {
  createCookie(name,"",-1);
}

// CALENDAR FUNCTIONS

// This function gets called when the end-user clicks on some date.
function selected(cal, date) {
  cal.sel.value = date; // just update the date in the input field.
  if (cal.dateClicked)
    // if we add this call we close the calendar on single-click.
    // just to exemplify both cases, we are using this only for the 1st
    // and the 3rd field, while 2nd and 4th will still require double-click.
    cal.callCloseHandler();
}

// And this gets called when the end-user clicks on the _selected_ date,
// or clicks on the "Close" button.  It just hides the calendar without
// destroying it.
function closeHandler(cal) {
  cal.hide();                        // hide the calendar
//  cal.destroy();
  _dynarch_popupCalendar = null;
}

// This function shows the calendar under the element having the given id.
// It takes care of catching "mousedown" signals on document and hiding the
// calendar if the click was outside.
function showCalendar(bel, format, showsTime, showsOtherMonths) {
  var el = bel.previousSibling;
  
  if (_dynarch_popupCalendar != null) {
    // we already have some calendar created
    _dynarch_popupCalendar.hide();                 // so we hide it first.
  } else {
    // first-time call, create the calendar.
    var cal = new Calendar(1, null, selected, closeHandler);
    // uncomment the following line to hide the week numbers
    // cal.weekNumbers = false;
    if (typeof showsTime == "string") {
      cal.showsTime = false;
      cal.time24 = (showsTime == "24");
    }
    if (showsOtherMonths) {
      cal.showsOtherMonths = true;
    }
    _dynarch_popupCalendar = cal;                  // remember it in the global var
    cal.setRange(1900, 2070);        // min/max year allowed.
    cal.create();
  }
  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use

  // the reference element that we pass to showAtElement is the button that
  // triggers the calendar.  In this example we align the calendar bottom-right
  // to the button.
  _dynarch_popupCalendar.showAtElement(bel, "Br");        // show the calendar

  return false;
}

