var state = 'none';

function ping(){
var theURL='ping.php';
 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
 xmlhttp.open("GET", theURL, false)
 xmlhttp.send()
}

function adminicotip(text) {
 document.getElementById("icondesc").innerHTML ="<font style='font-size:12px;font-weight:bold;color:white;padding:2px;background-image:url(../img/adminicotip.png);background-repeat:repeat-x;'>"+text+"</font>";
}

function adminclearicotip() {
 document.getElementById("icondesc").innerHTML ="&nbsp;";
}

function checkorderform() {
// check the form for all missing fields
	var value = document.orderform.name.value;
    if (value=='') {alert("Please write your name");document.orderform.name.focus();return false;}
    
   	var value = document.orderform.address.value;
    if (value=='') {alert("Please fill in your address");document.orderform.address.focus();return false;}  
    
    var value = document.orderform.town.value;
    if (value=='') {alert("Please fill in your town");document.orderform.town.focus();return false;}  
    
    var value = document.orderform.zip.value;
    if (value=='') {alert("Please fill in your Zip code");document.orderform.zip.focus();return false;}  
    
    var value = document.orderform.phone.value;
    if (value=='') {alert("Please fill in your phonenumber");document.orderform.phone.focus();return false;}  
    
    var value = document.orderform.email.value;
    var atpos = value.indexOf("@")
    var stoppos = value.lastIndexOf(".")
    if (value=='') {alert("Please fill in your email address, we will send the confirmation of your order to it.");document.orderform.email.focus();return false;}  

if (atpos==-1) {alert("Please fill in correct email address, we will send the confirmation of your order to it.");document.orderform.email.focus();return false;}

if (stoppos==-1) {alert("Please fill in correct email address, we will send the confirmation of your order to it.");document.orderform.email.focus();return false;}    

var questionresult = window.confirm("Are you sure to place an order?");

if (questionresult)
return true;
else
return false;
}


function checkform() {
// check the form for all missing fields
	var box = document.bookingform.bookingdate;
	var value = box.options[box.selectedIndex].value;
if (value<1) {alert("Please choose the date");document.bookingform.bookingdate.focus();return false;} 

// . . . . . . . . . 
	var box = document.bookingform.bookingpersons;
	var value = box.options[box.selectedIndex].value;
if (value<1) {alert("Please choose number of persons");document.bookingform.bookingpersons.focus();return false;} 

// . . . . . . . . . 
	var value = document.bookingform.bookingname.value;
if (value=="") {alert("Please enter your name");document.bookingform.bookingname.focus();return false;}

	var value = document.bookingform.bookinglastname.value;
if (value=="") {alert("Please enter your last name in second file");document.bookingform.bookinglastname.focus();return false;}

// . . . . . . . . . 
	var value = document.bookingform.bookingaddress.value;
if (value=="") {alert("Please enter your address");document.bookingform.bookingaddress.focus();return false;}  

// . . . . . . . . . 
	var value = document.bookingform.bookingtown.value;
if (value=="") {alert("Please enter your town");document.bookingform.bookingtown.focus();return false;}

// . . . . . . . . . 
	var value = document.bookingform.bookingphone.value;
if (value=="") {alert("Please enter your phonenumber on which we can contact you if necessary.");document.bookingform.bookingphone.focus();return false;}    

// . . . . . . . . . 
	var value = document.bookingform.bookingphone.value;
if (value=="") {alert("Please enter your country of residence.");document.bookingform.bookingcountry.focus();return false;}    

// . . . . . . . . . 
	var value = document.bookingform.bookingemail.value;
if (value=="") {alert("Please enter your email, we will send booking confirmation to it.");document.bookingform.bookingemail.focus();return false;}  

}

function showhide(layer_ref) {
if (state == 'block') {
state = 'none';
}
else {
state = 'block';
getdata('calendar/calendar.php','calendar');
}
if (document.all) { //IS IE 4 or 5 (or 6 beta)
eval( "document.all." + layer_ref + ".style.display = state");
}
if (document.layers) { //IS NETSCAPE 4 or below
document.layers[layer_ref].display = state;
}
if (document.getElementById &&!document.all) {
hza = document.getElementById(layer_ref);
hza.style.display = state;
}
} 

// here we define global variable

var ajaxdestination="";
var lastopened=""; // for menu
var t;

// here we start the newsbox rotator!
function rotatenews () {
t=setTimeout("rotatenews()",6000);
getdata("content/newbox.php","newscontainer","1");
}

function resetrotatenews() {
clearTimeout(t);
}

function restartrotatenews() {
t=setTimeout("rotatenews();",6000);
}

// end of news rotator
function isIE()
 {
  return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
 }

function scrolldiv(what) {
var browser=navigator.appName;
var ie=browser.indexOf("Internet Explorer");

if (ie>0) {
var y = document.documentElement.scrollTop;
} 
if (browser=="Netscape") {
var y = window.scrollY;
}
var rm = document.getElementById('what');
rm.style.top=y+'px';
rm.style.display='block';
}

function scrollreadmore() {
var browser=navigator.appName;
var ie=browser.indexOf("Internet Explorer");

if (ie>0) {
var y = document.documentElement.scrollTop;
} 
if (browser=="Netscape") {
var y = window.scrollY;
}
var rm = document.getElementById('readmore');
rm.style.top=y+'px';
rm.style.display='block';
}

function scrollrotateview() {
var browser=navigator.appName;
var ie=browser.indexOf("Internet Explorer");

if (ie>0) {
var y = document.documentElement.scrollTop;
} 
if (browser=="Netscape") {
var y = window.scrollY;
}
var rm = document.getElementById('rotateview');
rm.style.top=y+'px';
rm.style.display='block';
}

function getdata(what,where,noload) { // get data from source (what)
 try {
   xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
  		new ActiveXObject("Microsoft.XMLHTTP");
 }
 catch (e) { /* do nothing */ }
if (noload=='') {
 document.getElementById(where).innerHTML ="<center><img src='img/loading.gif'><br>Loading...</center>";
 }
// we are defining the destination DIV id, must be stored in global variable (ajaxdestination)
 ajaxdestination=where;
if (where!="") {
if (where=='newscontainer') {xmlhttp.onreadystatechange = triggerednewsblock;} else { xmlhttp.onreadystatechange = triggered;}
}
 xmlhttp.open("GET", what);
 xmlhttp.send(null);
//  return true;

}

function triggered() { // put data returned by requested URL to selected DIV
  if (xmlhttp.readyState == 4) if (xmlhttp.status == 200) 
   document.getElementById(ajaxdestination).innerHTML =xmlhttp.responseText;
}

function triggerednewsblock() { // workaround for IE :(
  if (xmlhttp.readyState == 4) if (xmlhttp.status == 200) 

   document.getElementById('newscontainer').innerHTML =xmlhttp.responseText;
}

function display (category) {
        if (lastopened==category) {lastopened='';}
	if (lastopened>'') {
	   var lastcategory = document.getElementById(lastopened);
           lastcategory.className="hide";
        }
	var whichcategory = document.getElementById(category);
	if (whichcategory.className=="show") {
		whichcategory.className="hide";
	} else {
		whichcategory.className="show";
		lastopened=category;
	}
}


