// JavaScript Document
function checkForm(formID)
{
	myForm = document.getElementById(formID);
	if (typeof(myForm) != "object") return false;
	myElements = myForm.elements;
	myError = new Array();
	for (f=0; f<myElements.length; f++){
		myElement = myElements[f];
		if (myElement.id.indexOf('_req') != -1){
			// REQUIRED FIELD
			if (myElement.id.indexOf('_em') != -1){
				if(myElement.value == "" || myElement.value.indexOf('@') == -1 || myElement.value.lastIndexOf('.') <= myElement.value.indexOf('@')){
					myError.push(myElement);
				}
			} else if (myElement.value == "" || (myElement.type == "checkbox" && myElement.checked != true)) {
				myError.push(myElement);
			}
		}
	}
	if (myError.length > 0){
		for (f=0; f<myError.length; f++){
			myError[f].className = "input-error";
		}
		return false;
	} else { 
		return true;
	}
	return false;
}
function checkInquiry(formID){	
	if(document.getElementById('inquiryRegion').options[document.getElementById('inquiryRegion').selectedIndex].value == 'error'){
		alert('Bitte wählen Sie eine Region!');
		return false;
	} else return true;
}


function showDiv(divID)
{
	var GECKO = document.getElementById? 1:0 ;
	var NS = document.layers? 1:0 ;
	var IE = document.all? 1:0 ;

	if (GECKO) {
		document.getElementById(divID).style.display='block';
	}
	else if (NS) {
		document.layers[divID].display='block';
	}
	else if (IE) {
		document.all[divID].style.display='block';
	}
}

function hideDiv(divID)
{
	var GECKO = document.getElementById? 1:0 ;
	var NS = document.layers? 1:0 ;
	var IE = document.all? 1:0 ;

	if (GECKO) {
		document.getElementById(divID).style.display='none';
	}
	else if (NS) {
		document.layers[divID].display='none';
	}
	else if (IE) {
		document.all[divID].style.display='none';
	}
}

function checkAccommodation()
{

}

function ShowImageGallery(){
	var GalleryWindow;
	GalleryWindow = window.open('http://www.hotels-in-tirol.at/includes/window-impressions.php', '', 'height=400, width=800');
}

function ShowOldTyrol(){
	var GalleryWindow;
	GalleryWindow = window.open('http://www.hotels-in-tirol.at/includes/window-old-tyrol.php', '', 'height=400, width=800');
}

function ShowTellFriend()
{
	window.open('http://www.hotels-in-tirol.at/includes/window-send.php', '', 'height=250, width=400');
}


function setSorting(flag, order){
	document.location.href= BASE_HREF + "sort/" + flag + "/order/" + order
}

function CreateBookmarkLink(Title, URL)
{
	if (window.sidebar)
	{
		window.sidebar.addPanel(Title, URL, "");
	}
	else if (window.external)
	{
		window.external.AddFavorite(URL, Title);
	}
	return true;
 }
function popup(w,h,url)
{
	x = screen.availWidth/2-w/2;
	y = screen.availHeight/2-h/2;
	var popupWindow = window.open(
		url,'','width='+w+',height='+h+',left='+x+',top='+y+',screenX='+x+',screenY='+y+',scrollbars=no');
}

function change_focus(obj, chars, fields)
{
	if(obj.id < fields)
	{
		if(obj.value.length >= chars)
		{
			obj.blur();
			document.getElementById((obj.id*1+1)+"").focus();
		}
	}
}