isNS = (navigator.appName == 'Netscape');
isIE = (navigator.appName.indexOf('Microsoft') != -1);
isOP = (navigator.appName == 'Opera');
ns4 = (document.layers);
ie4 = (document.all && !document.getElementById);
ie5 = (document.all && document.getElementById);
ns6 = (!document.all && document.getElementById);
useSWF = true;

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function xGetElementById(e) {
	if(typeof(e)!='string') return e;
	if(document.getElementById) e=document.getElementById(e);
	else if(document.all) e=document.all[e];
	else e=null;
	return e;
}
function xInnerHtml(e,h){
	if(!(e=xGetElementById(e)) || !xStr(e.innerHTML)) return null;
	var s = e.innerHTML;
	if (xStr(h)) {e.innerHTML = h;}
	return s;
}
function xStr(s){
	for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
	return true;
}
// za menuto ot diasno - setvane H na objecta
function setHeight (el, n) {
	var elHeight = 27;
	var the_height = n*elHeight + 94; // document.body.scrollHeight;
	var obj = xGetElementById(el);
	while (!obj) {
		obj = xGetElementById(el);
		break;
	}
	obj.style.height = (isIE) ? the_height : the_height+'px';
}

function over(koi){
var obj = document.getElementById(koi);
   obj.src = "/images_new/menu/"+koi+"_over.jpg";
}

function out(koi){
var obj = document.getElementById(koi);
   obj.src = "/images_new/menu/"+koi+".jpg";
}

function init(current) {
 var obj_n = document.getElementById('m'+current);
 var obj2_n = document.getElementById('sm'+current);
   obj_n.style.backgroundColor = "#e7d9b2";
   obj2_n.style.backgroundColor = "#863313";
}

function InsertSampleMovie()
{
document.write('<object classid="clsid: 02BF25D5" ...>\n');
document.write('<param name="src" value="quicktime/panorama_foaie.mov" />\n');
document.write('</object>\n');
}

function change_pic(pic_id, pic_src) {
  var obj = document.getElementById(pic_id);
  obj.src = pic_src;
}

/*function change_room(room) {

  var img_txt = "";
  var img_room=new Array("0","3","4","3","4","6","5","5","5","3");
  img_txt+='<div style="position: absolute; left: 128px; top: 25px;"><img width="268" height="180" id="big"></div>';
  img_txt+='<div style="position: absolute; left: 117px; top: 225px;">';
  for (i = 1; i <=img_room[room]; i++) 
  	{		
		img_txt+='<a style="cursor: pointer" onClick="change_pic(\'big\', document.reservation.tip.value+\'/'+i+'.jpg\')"><img width="93" height="66" id="small_'+i+'"></a>&nbsp;';
		if (i%3==0) {
			img_txt+='</div><div style="position: absolute; left: 117px; top: 295px;">';
		}		
	}
  img_txt+='</div>';
  document.getElementById('room_images').innerHTML = img_txt;
  document.getElementById('big').src = room+"/1.jpg";
    for (i = 1; i <=img_room[room]; i++) 
  	{		
		document.getElementById('small_'+i).src = room+"/"+i+"_ico.jpg";
	}
}*/

function change_room(room) {

  var img_txt = "";
  img_txt+='<div style="position: absolute; left: 128px; top: 25px;"><img width="268" height="180" id="big"></div>';
  img_txt+='<div style="position: absolute; left: 117px; top: 225px;">';
  var snimki = room_sn[room].split(",");
  for (i = 1; i <=room_br[room]; i++) 
  	{	
		var img_id = snimki[i-1].split(".");
		img_txt+='<a style="cursor: pointer" onClick="change_pic(\'big\', \'/reservation/snimki/'+snimki[i-1]+'\')"><img width="93" height="66" id="small_'+img_id[0]+'"></a>&nbsp;';
		if (i%3==0) {
			img_txt+='</div><div style="position: absolute; left: 117px; top: 295px;">';
		}		
	}
  img_txt+='</div>';
  document.getElementById('room_images').innerHTML = img_txt;
  document.getElementById('big').src = "/reservation/snimki/"+snimki[0];
    for (i = 1; i <=room_br[room]; i++) 
  	{		
		var img_id = snimki[i-1].split(".");
		document.getElementById('small_'+img_id[0]).src = "/reservation/snimki/"+img_id[0]+"_ico."+img_id[1];
	}
}


// ****** startup *********
window.onload = function () {
	// window.location = "#link_here"
//	window.focus();
}

 function sh_div(what) {
	 var i=0;
	 var coll = [];
	 while (document.getElementById('d'+ i)) {
	  coll[i] = document.getElementById('d'+ i);
		i++;
	 }
 obj = document.getElementById(what);
 var i=0;
 if (obj.className == 'off') {
	 while (coll[i]) {
		coll[i].className = 'off';
		i++;
		} 
	obj.className = 'on';
 } else {
	obj.className = 'off';
 }
}

function guestbook_send(f, pole1, pole2) {
     var what = "Въведете име и мнение!";
     var obj = document.getElementById(f);	 
  if ((obj[pole1].value == "") || (obj[pole2].value == "")) {
    alert (what);
		return false;
   } else {
    obj.submit();
  }
}

function calcHeight_admin(koi) {
	var the_height=document.body.scrollHeight;
	var obj = parent.document.getElementById(koi);
	obj.style.height = (!isNS && !isOP) ? the_height : the_height+'px';
}

function calcHeight(koi) {
	crawler();
	var the_height=document.body.scrollHeight;
	var obj = parent.document.getElementById(koi);
	obj.style.height = (!isNS && !isOP) ? the_height : the_height+'px';
}

function PopupPic(sPicURL) { 
     window.open( "/popup.html?"+sPicURL, "",  
     "resizable=1,HEIGHT=200,WIDTH=200, left=3, top=5"); 
   }
   
function check_form(form, pole1, pole2, pole3, pole4, pole5, pole6, pole7){
	var obj1 = document.getElementById('email');
	var email = obj1.value;
	var emailRegxp = /^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/;
    var what1 = "Моля, попълнете всички полета маркирани със *";
    var obj = document.getElementById('reservation');
	
	var data_ot = document.getElementById(pole4).value;
	var data_do = document.getElementById(pole5).value;
	var data1 = data_ot.substr(6,4)+data_ot.substr(3,2)+data_ot.substr(0,2);
	var data2 = data_do.substr(6,4)+data_do.substr(3,2)+data_do.substr(0,2);
	
  if ((obj[pole1].value == "") || (obj[pole2].value == "") || (obj[pole3].value == "") || (obj[pole4].value == "") || (obj[pole5].value == "") || (obj[pole6].value == "") || (obj[pole7].value == "")) {
    alert (what1);
		return false;
  } else if ((emailRegxp.test(email) != true) || (email == "")) {
		alert("Моля, въведете валиден e-mail адрес!");
		return false;
  } else if (data1>data2) {
		alert("Датата на заминаване не може да предхожда датата на пристигане!");
		return false;
  } else {
	  		//return proverka('reservation', 'idto[]');
			obj.submit();
  		 }
    //obj.submit();
  //}
}

function proverka(FormName, FieldName)
{
var obj = document.getElementById('reservation');
var objCheckBoxes = document.forms[FormName].elements[FieldName];
var countCheckBoxes = objCheckBoxes.length;
var izhod="";

var staq_tip = obj.tip.selectedIndex;
var selected_staqtip = obj.tip.options[staq_tip].text;


for(var i = 0; i < countCheckBoxes; i++)
       if (objCheckBoxes[i].checked)
	   		{   
				chk="idto_"+objCheckBoxes[i].value;
				izhod+=obj.elements[chk].value+", ";				
			}
			extras=(izhod.substring(0,((izhod.length)-2)));
			
	   if (confirm('Вашата заявка е следната: \n \n'+
                		  'име: '+obj.ime.value+'\n'+
                		  'фамилия: '+obj.familia.value+'\n'+
                          'e-mail: '+obj.email.value+'\n'+
                          'дата на пристигане: '+obj.date_start.value+'\n'+
                          'дата на заминаване: '+obj.date_end.value+'\n'+
                          'тип стая: '+selected_staqtip+'\n'+ 
                          'брой гости: '+obj.gosti.value+'\n'+                         
                          'допълнителни услуги: '+extras+'\n'+
                          'допълнителна информация: '+obj.info.value+'\n \n'+
						  'Желаете ли да продължите?')) 
				{	
					obj.submit();
				}   
					else  
						{
							return false;	
						}		
}


function filterInput(filterType, evt, allowDecimal, allowCustom){ 
    var keyCode, Char, inputField, filter = ''; 
    var alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; 
    var num   = '0123456789'; 
    // Get the Key Code of the Key pressed if possible else - allow 
    if(window.event){ 
        keyCode = window.event.keyCode; 
        evt = window.event; 
    }else if (evt)keyCode = evt.which; 
    else return true; 
    // Setup the allowed Character Set 
    if(filterType == 0) filter = alpha; 
    else if(filterType == 1) filter = num; 
    else if(filterType == 2) filter = alpha + num; 
    if(allowCustom)filter += allowCustom; 
    if(filter == '')return true; 
    // Get the Element that triggered the Event 
    inputField = evt.srcElement ? evt.srcElement : evt.target || evt.currentTarget; 
    // If the Key Pressed is a CTRL key like Esc, Enter etc - allow 
    if((keyCode==null) || (keyCode==0) || (keyCode==8) || (keyCode==9) || (keyCode==13) || (keyCode==27) )return true; 
    // Get the Pressed Character 
    Char = String.fromCharCode(keyCode); 
    // If the Character is a number - allow 
    if((filter.indexOf(Char) > -1)) return true; 
    // Else if Decimal Point is allowed and the Character is '.' - allow 
    else if(filterType == 1 && allowDecimal && (Char == '.') && inputField.value.indexOf('.') == -1)return true; 
    else return false; 
}

function usl_check(form,pole1,lang,url)
{
	var objCheckBox = document.forms[form].elements[pole1];
	if (lang == 'bg') {
		mess = "Трябва да се съгласите с условията!";
	} else if (lang == 'en') {
		mess = "Трябва да се съгласите с условията!";
	} else if (lang == 'ru') {
		mess = "Трябва да се съгласите с условията!";
	}
	
	       if (objCheckBox.checked)
	   			{   
					window.open(url, '_self');
				}
		   else {
			   		alert (mess);
					return false;
		   		}

}

function Clickheretoprint(what, lang) {
	if (lang == 'bg') {
		message = "Документ за извършено разплащане през уеб сайта на <b>Гранд хотел Поморие</b>";
	} else if (lang == 'en') {
		message = "Document for a payment transaction made by the website of <b>Grand hotel Pomorie</b>";
	} else if (lang == 'ru') {
		message = "Документ оплаты через уеб сайт компании <b>Grand hotel Pomorie</b>";
	}

		var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
		    disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25, resizable=yes"; 
		var content_value = document.getElementById(what).innerHTML; 
		
		var docprint=window.open("","",disp_setting); 
			docprint.document.open(); 
			docprint.document.write('<html><head><title>GRAND HOTEL POMORIE</title>'); 
			docprint.document.write('<link href="/print.css" rel="stylesheet" type="text/css">');


			docprint.document.write('</head><body onLoad="self.print()" style="background-color: #FFFFFF; background-image:none;">');
			docprint.document.write('<div align="left"><img src="/images/hotel_logo_white.gif"></img></div>');  
			docprint.document.write('<div align="left" style="padding: 20px 0 20px 80px">'+message+'</div>');    
			docprint.document.write('<div align="left" style="padding: 20px 0 20px 80px">'+content_value+'</div>');    
			docprint.document.write('<p align="left" class="t14 bold"><b>www.grandhotelpomorie.com</p>');          
			docprint.document.write('</body></html>'); 
			docprint.document.close(); 
			docprint.focus(); 
}


function banner_send(f, pole1, pole2) {
     var what = "Изберете снимка и въведете url";
     var obj = document.getElementById(f);
	 str = obj.image.value;
  if ((obj[pole1].value == "") || (obj[pole2].value == "")) {
    alert (what);
		return false;
   } 
	 else   {
				ext = str.substring(str.length,str.length-3);	
				ext=ext.toLowerCase();				
				if ( (ext!="jpg") && (ext!="gif") && (ext!="png") )
					{						   
						alert ("Файлът не е с необходимото разширение!")
						return false
					}
							
				else 
					{ 		
   						 obj.submit();
					} 
			}			
}


