$(document).ready(function() {
	$("a.lightbox").fancybox();
});

// zablokovanie inputov
function enable(txt){
	var miesto = document.getElementById('miesto_rezervovania').value;
	if (miesto=="Letisko Bratislava" || miesto=="Letisko Viedeň") {
		if (txt) {alert (txt)};
		document.getElementById("cislo_letu").disabled = false;
		document.getElementById("destinacia_letu").disabled = false;
	} else {
		document.getElementById("cislo_letu").disabled = true;
		document.getElementById("destinacia_letu").disabled = true;
	}
}

// submiting form to any location
function move(target){
	document.getElementById('multiple_form').action = target;
	document.getElementById('multiple_form').submit();
}
// delete confirm
function jsconfirm(thetext){
	return confirm(thetext);
}

function init(){
	if (!document.layers) return;
	var box = document.getElementById('custom-form').elements;
	for (var i=0;i<box.length;i++){
		box[i].disabled = true;
	}
}
function disableIt(obj){
	obj.disabled = !(obj.disabled);
	var z = (obj.disabled) ? 'disabled' : 'enabled';
}
function extracheck(obj){
	return !obj.disabled;
}
// zobrazenie skrytie galerii
function toggle5(showHideDiv, switchImgTag, showImage, hideImage) {
	var ele = document.getElementById(showHideDiv);
	var imageEle = document.getElementById(switchImgTag);
	if(ele.style.display == "block") {
		ele.style.display = "none";
		imageEle.innerHTML = '<img src="'+ showImage +'" alt="zobraziť" />';
	}
	else {
		ele.style.display = "block";
		imageEle.innerHTML = '<img src="'+ hideImage +'" alt="skryť" />';
	}
}

// star rating
function datosServidor() {
};
datosServidor.prototype.iniciar = function() {
	try {
		// Mozilla / Safari
		this._xh = new XMLHttpRequest();
	} catch (e) {
		// Explorer
		var _ieModelos = new Array(
		'MSXML2.XMLHTTP.5.0',
		'MSXML2.XMLHTTP.4.0',
		'MSXML2.XMLHTTP.3.0',
		'MSXML2.XMLHTTP',
		'Microsoft.XMLHTTP'
		);
		var success = false;
		for (var i=0;i < _ieModelos.length && !success; i++) {
			try {
				this._xh = new ActiveXObject(_ieModelos[i]);
				success = true;
			} catch (e) {
			}
		}
		if ( !success ) {
			return false;
		}
		return true;
	}
}

datosServidor.prototype.ocupado = function() {
	estadoActual = this._xh.readyState;
	return (estadoActual && (estadoActual < 4));
}

datosServidor.prototype.procesa = function() {
	if (this._xh.readyState == 4 && this._xh.status == 200) {
		this.procesado = true;
	}
}

datosServidor.prototype.enviar = function(urlget,datos) {
	if (!this._xh) {
		this.iniciar();
	}
	if (!this.ocupado()) {
		this._xh.open("GET",urlget,false);
		this._xh.send(datos);
		if (this._xh.readyState == 4 && this._xh.status == 200) {
			return this._xh.responseText;
		}
		
	}
	return false;
}


function _gr(reqseccion,divcont) {
	remotos = new datosServidor;
	nt = remotos.enviar(reqseccion,"");
	document.getElementById(divcont).innerHTML = nt;
}


function rateImg(rating,id,state)  {
	if (state==1) {
		remotos = new datosServidor;
		nt = remotos.enviar('index.php?rating='+rating+'&post_id='+id);
		alert('Ďakujeme za Váš hlas');
		rating = rating * 20;
		document.getElementById('current-rating-'+id).style.width = rating+'px';
		document.getElementById('ratelinks-'+id).style.display = 'none';
		document.getElementById('ratingtext-'+id).innerHTML = 'Ďakujeme za Váš hlas';
	}
	else {
		document.getElementById('ratingtext-'+id).innerHTML = 'Ľutujeme, ale Váš hlas je už zaznamenaný.';
		alert('Ľutujeme, ale Váš hlas je už zaznamenaný');
	}
}

