<!--

/*
 * runOnLoad.js: portable registration for onload event handlers.
 *
 * This module defines a single runOnLoad( ) function for portably registering
 * functions that can be safely invoked only when the document is fully loaded
 * and the DOM is available.
 *
 * Functions registered with runOnLoad( ) will not be passed any arguments when
 * invoked. They will not be invoked as a method of any meaningful object, and
 * the this keyword should not be used. Functions registered with runOnLoad( )
 * will be invoked in the order in which they were registered. There is no
 * way to deregister a function once it has been passed to runOnLoad( ).
 *
 * In old browsers that do not support addEventListener( ) or attachEvent( ),
 * this function relies on the DOM Level 0 window.onload property and will not
 * work correctly when used in documents that set the onload attribute
 * of their <body> or <frameset> tags.
 */
function runOnLoad(f) {
    if (runOnLoad.loaded) f( );    // If already loaded, just invoke f( ) now.
    else runOnLoad.funcs.push(f); // Otherwise, store it for later
}

runOnLoad.funcs = []; // The array of functions to call when the document loads
runOnLoad.loaded = false; // The functions have not been run yet.

// Run all registered functions in the order in which they were registered.
// It is safe to call runOnLoad.run( ) more than once: invocations after the
// first do nothing. It is safe for an initialization function to call
// runOnLoad( ) to register another function.
runOnLoad.run = function( ) {
    if (runOnLoad.loaded) return;  // If we've already run, do nothing

    for(var i = 0; i < runOnLoad.funcs.length; i++) {
        try { runOnLoad.funcs[i]( ); }
        catch(e) { /* An exception in one function shouldn't stop the rest */ }
    }

    runOnLoad.loaded = true; // Remember that we've already run once.
    delete runOnLoad.funcs;  // But don't remember the functions themselves.
    delete runOnLoad.run;    // And forget about this function too!
};

// Register runOnLoad.run( ) as the onload event handler for the window
if (window.addEventListener)
    window.addEventListener("load", runOnLoad.run, false);
else if (window.attachEvent) window.attachEvent("onload", runOnLoad.run);
else window.onload = runOnLoad.run;


function getStyle(el, styleProp) {
	//var el = document.getElementById(id);
	if (el.currentStyle)
		var y = el.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(el, null).getPropertyValue(styleProp);
	return y;
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft, curtop];
}

function windowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [myWidth, myHeight];
}

function changePosition(el, left, top, width, height) {
	el.style.left = left + 'px';
	el.style.width = width + 'px';
	el.style.top = top + 'px';
	el.style.height = height + 'px';
}

function changeOpacity(id, opacity) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = 'alpha(opacity=' + opacity + ')';
}

function animateElement(id, wdir, hdir, steps, easing, n) {
	var el = document.getElementById(id);
	var wrapper = el.parentNode;
	var wmax = el.offsetWidth;
	var hmax = el.offsetHeight;
	var status = wrapper.rel;
	var dir = (status) ? 1 : -1;
	if (!n) n = 1;
	if (steps == 0) steps = (wmax >= hmax) ? parseInt(wmax / 40) : parseInt(wmax / 40);
	if (steps > wmax) steps = wmax;
	if (steps > hmax) steps = hmax;
	if (easing <= 0) easing = 0;
	if (easing > 2) easing = 2;
	var p = (dir == -1) ? (n / steps) : (steps - n) / steps;
	if (easing != 0) p = Math.pow(p, easing);
	var wdiff = parseInt(p * wmax);
	var hdiff = parseInt(p * hmax);
	var width = (wdir == 0) ? width = wmax : wdiff;
	var height = (hdir == 0) ? height = hmax : hdiff;
	var left = (wdir == -1) ? wrapper.offsetLeft - (width - wrapper.offsetWidth) : wrapper.offsetLeft;
	var top = (hdir == -1) ? wrapper.offsetTop - (height - wrapper.offsetHeight) : wrapper.offsetTop;
	if (wdir == -1) el.style.left = (width - wmax) + 'px';
	wrapper.style.left = left + 'px';
	if (wdir != 0) wrapper.style.width = width + 'px';
	if (hdir == -1) el.style.top = (height - hmax) + 'px';
	wrapper.style.top = top + 'px';
	if (hdir != 0) wrapper.style.height = height + 'px';
	changeOpacity(id, parseInt(p * 100));
	if (n < steps) {
		window.setTimeout('animateElement("' + id + '", ' + wdir + ', ' + hdir + ', ' + steps + ', ' + easing + ', ' + (n + 1) + ')', 1);
	} else {
		//changePosition(wrapper, left, top, (wmax - wb), (hmax - hb));
		wrapper.rel = !status;
	}
}

function externalLinks() {   
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
 	}   
}   

runOnLoad(externalLinks);

function decrypt(text) {
	var text_encrypted = "";
	for (i = 1 ; i < (text.length + 1); i++) {
		k = text.charCodeAt(i-1);
		if (k >= 97 && k <= 109) {
			k = k + 13;
		} else
			if (k >= 110 && k <= 122) {
				k = k - 13;
			} else
				if (k >= 65 && k <= 77) {
					k = k + 13;
				} else
					if (k >= 78 && k <= 90) {
						k = k - 13;
					}
		text_encrypted = text_encrypted + String.fromCharCode(k);
	}
	return text_encrypted;
}

function animateHeight(id, size)
{
el = document.getElementById(id);
var h_size1 = el.offsetHeight;
if (h_size1 < size)
{
el.style.height = h_size1 + 1 + "px";
setTimeout("animateHeight('" + id + "','" + size + "')", 1);
}
}

function animateWidth(id, size)
{
el = document.getElementById(id);
var w_size1 = el.offsetWidth;
if (w_size1 < size)
{
el.style.width = w_size1 + 1 + "px";
setTimeout("animateWidth('" + id + "','" + size + "')", 1);
}
}

function showlogin(el) {
	var loginbox = document.getElementById('loginbox');
	var prijava = document.getElementById('prijava');
	if (loginbox.style.visibility == 'visible') {
		loginbox.style.visibility = 'hidden'
	} else {
		loginbox.style.left = findPos(prijava)[0] - 150 + 'px';
		loginbox.style.top = findPos(prijava)[1] + 10 + 'px';
		loginbox.style.height = '10px';
		loginbox.style.visibility = 'visible'
		animateHeight('loginbox', 160);
	}	
}

function preloadImages() {
  if(document.images) {
    if(!document.imageArray) document.imageArray = new Array();
    var i,j = document.imageArray.length, args = preloadImages.arguments;
    for(i=0; i<args.length; i++) {
      if (args[i].indexOf("#")!=0) {
        document.imageArray[j] = new Image;
        document.imageArray[j++].src = args[i];
      }
    }
  }
}

function new_window(url) {
	var oWin = window.open(url, '_blank'); 
	if (oWin) { 
	if (oWin.focus) oWin.focus(); 
		return false; 
	} 
	oWin = null; 
	return true; 
}

function ajaxFunction(page, el) {
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();  
	} catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			document.getElementById(el).innerHTML=xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET",page.replace("&amp;","&"),true);
	xmlHttp.send(null);
	return true;
}

function FN(n, totalDigits) { 
	n = n.toString(); 
	var pd = ''; 
	if (totalDigits > n.length) {
		for (i=0; i < (totalDigits-n.length); i++) {
			pd += '0';
		};
	};
	return pd + n.toString();
}

function getSelectValue(el) {
	var value = el.options[el.options.selectedIndex].value;
	return value;
}

function getSelectValueById(id) {
	var el = document.getElementById(id);
	var value = el.options[el.options.selectedIndex].value;
	return value;
}












$(function() {
	$.datepicker.setDefaults($.datepicker.regional[lang]);
	$.datepicker.setDefaults({
		dateFormat: 'dd/mm/yy'
	});
});

$.datepicker.setDefaults({
	defaultDate: 0,
	minDate: 0,
	showOtherMonths: true,
	selectOtherMonths: true
});


$(document).ready(function() {
	
	$('#fcode').val('');
	$('#fca').append(
		$('<img />').click(function() {
			var d = new Date();
			var s = '/ab2';
			s += '/c5.asp';
			s += '?' + d.getTime().toString(10);
			$(this).attr('src', s);
		}).click()
	);
	
	$(function () {
    	$('#arrival').datepicker({ minDate: 0 });
	});
	
	
	
	var defaultSearchText = 'Search istra.net';
	
	function UpdateSearchField() {
		var el = $('#searchText');
		var text = $(el).val();
		
		if (text == '') {
			$(el).val(defaultSearchText).css({'color': '#999999', 'font-style': 'italic'});
		} else {
			$(el).css({'color': '#000000', 'font-style': 'normal'});
		};
	};
	
	$('#searchText').focus(function() {
		var el = $('#searchText');
		var text = $(el).val();
		
		if (text == defaultSearchText) {
			el.val('').css({'color': '#000000', 'font-style': 'normal'});
		};
	});
	
	$('#searchText').blur(function() {
		var el = $('#searchText');
		var text = $(el).val();
		
		if (text == '') {
			el.val(defaultSearchText).css({'color': '#999999', 'font-style': 'italic'});
		};
	});
	
	$('#searchForm').submit(function() {
		var el = $('#searchText');
		var text = $(el).val();
		
		if (text == '' || text == defaultSearchText) return false;
	});
	
	$('#searchText').val('');
	UpdateSearchField();
	
});


-->
