function makeToolTips($id){
	if ($.browser.msie && $.browser.version == '6.0' ) return;
	if(!$id) $id = '[title!=""]';
	//$($id).easyTooltip();
	$($id).qtip({
		style: {    
			border: { width: 1, radius: 2, color: '#FEE2A4' },
			background: '#FFF',
			tip: true
		},
		show: { delay:300	}
	});
}

function ch_travel_type(id){
	travel_type=document.search.travel_type.value;
	destination=document.search.destination;
	var destination_sel=(id)?id:destination.options[destination.selectedIndex].value;
	destination.options.length = 1;
	if(travel_type=='rest'){
		for(i=0;i<rest_countrys.length;i++){
			destination.options[i+1] = new Option(rest_countrys[i],rest_countrys_codes[i]);
		}
	}
	if(travel_type=='know'){
		for(i=0;i<know_countrys.length;i++){
			destination.options[i+1] = new Option(know_countrys[i],know_countrys_codes[i]);
		}
	}
	if(travel_type=='rest_know'){
		for(i=0;i<rest_know_countrys.length;i++){
			destination.options[i+1] = new Option(rest_know_countrys[i],rest_know_countrys_codes[i]);
		}
	}
	if(travel_type=='far'){
		for(i=0;i<far_countrys.length;i++){
			destination.options[i+1] = new Option(far_countrys[i],far_countrys_codes[i]);
		}
	}
	if(travel_type=='skiing'){
		for(i=0;i<skiing_countrys.length;i++){
			destination.options[i+1] = new Option(skiing_countrys[i],skiing_countrys_codes[i]);
		}
	}
	for(i=0;i<destination.options.length;i++){
		if(destination.options[i].value==destination_sel)destination.options[i].selected=true;
	}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function show(ob){
	o=document.getElementById(ob);
	o.style.display="block";
}
function hide(ob){
	o=document.getElementById(ob);
	o.style.display="none";
}

function getPage(thePage,wt,ht){ 
if(wt=="")wt=300;
if(ht=="")wt=300;
leftPos= (screen.width-wt)/2 
topPos = (screen.height-ht)/2
rnd = Math.round(1000*Math.random());
newWin1 = window.open(thePage,'popup'+rnd,'toolbars=no,resizable=yes,scrollbars=yes,left='+leftPos+',top='+topPos+',width='+wt+',height='+ht) 
} 

function getMap(thePage,wt,ht){ 
if(wt=="")wt=300;
if(ht=="")wt=300;
leftPos= (screen.width-wt)/2 
topPos = (screen.height-ht)/2
rnd = Math.round(1000*Math.random());
newWin1 = window.open(thePage,'popup'+rnd,'toolbars=no,resizable=yes,scrollbars=no,status=yes,left='+leftPos+',top='+topPos+',width='+wt+',height='+ht) 
} 

function popImg(thePage,wt,ht){ 
if(!wt)wt=300;
if(!ht)ht=300;
//leftPos= (screen.width-wt)/2 
//topPos = (screen.height-ht)/2 
leftPos=100;
topPos =100;
newWin1 = window.open("/view_image.php?src="+thePage,'aWin2','toolbars=no,resizable=yes,scrollbars=no,status=yes,left='+leftPos+',top='+topPos+',width='+wt+',height='+ht) 
} 

// prevents IE from flickering background images
try {  document.execCommand('BackgroundImageCache', false, true);} catch(e) {}

function doPrint(id) {
	newwindow2=window.open('','printWindow','height=500,width=700,resizable=yes,scrollbars=yes');
	var tmp = newwindow2.document;
	tmp.write('<html><head><title>Spausdinti</title>');
	tmp.write('<link rel="stylesheet" href="/css/vidinis.css">');
	tmp.write('</head><body onload="window.focus();window.print();window.close();">');
	tmp.write('<table bgcolor="#FFFFFF"><tr><td width="725" align="left" valign="top" class="lent_content">');
	tmp.write(document.getElementById(id).innerHTML);
	tmp.write('</td></tr></table></body></html>');
	tmp.close();
}

function doPrintTravel(id) {
	newwindow2=window.open('','printWindow','height=500,width=700,resizable=yes,scrollbars=yes');
	var tmp = newwindow2.document;
	tmp.write('<html><head><title>Spausdinti</title>');
	tmp.write('<link rel="stylesheet" href="/css/vidinis.css">');
	tmp.write('</head><body onload="window.focus();window.print();window.close();">');
	tmp.write('<table bgcolor="#FFFFFF"><tr><td width="725" align="left" valign="top" class="lent_content">');
	tmp.write(document.getElementById(id).innerHTML);
	tmp.write('</td></tr></table></body></html>');
	tmp.close();
}


function chDate(){
	date_f=document.search.date_f.value;
	date_t=document.search.date_t.value;
	//if(date_t.replace(/-/g, "")<date_f.replace(/-/g, "")){
		document.search.date_t.value="";
	//}
}

var home;
var search;
function show(ob)
{	
	o=document.getElementById(ob);
	o.style.display="block";
	
	// START FIX IE6 bug
	if(navigator.userAgent.toLowerCase().indexOf("msie 6.")!=-1 && search){
		if(document.getElementById('nav_destination').style.display=="block" 
		){
			hidden(document.getElementById('travel_type'));
		}
		if(document.getElementById('nav_know').style.display=="block" 
			|| document.getElementById('nav_far').style.display=="block"
		){
			hidden(document.getElementById('travel_type'));
			hidden(document.getElementById('destination'));
		}
		if(document.getElementById('nav_info').style.display=="block" 
		){
			hidden(document.getElementById('child3'));
		}
		if(document.getElementById('nav_skiing').style.display=="block" 
		){
			hidden(document.getElementById('destination'));
			hidden(document.getElementById('theme'));
		}
	}
	// END FIX IE6 bug

}
function hide(ob){
	o=document.getElementById(ob);
	o.style.display="none";

	// START FIX IE6 bug
	if(navigator.userAgent.toLowerCase().indexOf("msie 6.")!=-1 && search){
		if(
			 document.getElementById('nav_destination').style.display=="none" 
			&& document.getElementById('nav_know').style.display=="none" 
			&& document.getElementById('nav_far').style.display=="none"){
			visible(document.getElementById('travel_type'));
			visible(document.getElementById('destination'));
		}
		if(
			 document.getElementById('nav_destination').style.display=="none" 
			&& document.getElementById('nav_know').style.display=="none" 
			&& document.getElementById('nav_far').style.display=="none"){
			visible(document.getElementById('travel_type'));
			visible(document.getElementById('destination'));
		}
		if(document.getElementById('nav_info').style.display=="none" 
		){
			visible(document.getElementById('child3'));
		}
		if(document.getElementById('nav_skiing').style.display=="none" 
		){
			visible(document.getElementById('theme'));
		}
	}
	// END FIX IE6 bug

}

function hidden(f){
	if(f){
		f.style.visibility = 'hidden';
	}
}
function visible(f){
	if(f){
		f.style.visibility = 'visible';
	}
}

function offersOption(o){
	if(!home) return
	var offers=document.getElementById('offers');
	if(navigator.userAgent.toLowerCase().indexOf("msie")!=-1){				
		if(o=='disable'){
			offers.style.zIndex=-1;
		}else{
			offers.style.zIndex=0;
		}
	}
}

//AjaxReq("/xml/recommendOffers.php?group="+group,'RecommendOffersCallback(xmlHttp)');
function AjaxReq(url,callback)
{
	var xmlHttp;
	xmlHttp = false;
  // branch for native XMLHttpRequest object
	if(window.XMLHttpRequest && !(window.ActiveXObject)) {
		try {
			xmlHttp = new XMLHttpRequest();
		} catch(e) {
			xmlHttp = false;
		}
	// branch for IE/Windows ActiveX version
	} else if(window.ActiveXObject) {
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch(e) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				xmlHttp = false;
			}
		}
	}
	if(xmlHttp) {
		xmlHttp.onreadystatechange = function() { eval(callback); }
		//prenumerataCallback(xmlHttp);
		xmlHttp.open("GET", url, true);
		xmlHttp.send("");
	}
}

function handler(id){
	if(document.getElementById(id).style.display != 'block')
		document.getElementById(id).style.display = 'block';
	else
		document.getElementById(id).style.display = 'none';
}

function handler_submit_button(value)
{
	if (document.getElementById("reg_form_accept").checked == true)
	{
		document.getElementById("reg_on").style.display = 'block';
		document.getElementById("reg_off").style.display = 'none';
	}
	else
	{
		document.getElementById("reg_off").style.display = 'block';
		document.getElementById("reg_on").style.display = 'none';
	}
}

function sprintf()
{
	if (!arguments || arguments.length < 1 || !RegExp)
	{
		return;
	}
	var str = arguments[0];
	var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/;
	var a = b = [], numSubstitutions = 0, numMatches = 0;
	while (a = re.exec(str))
	{
		var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
		var pPrecision = a[5], pType = a[6], rightPart = a[7];
		
		//alert(a + '\n' + [a[0], leftpart, pPad, pJustify, pMinLength, pPrecision);

		numMatches++;
		if (pType == '%')
		{
			subst = '%';
		}
		else
		{
			numSubstitutions++;
			if (numSubstitutions >= arguments.length)
			{
				alert('Error! Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\nfor the number of substitution parameters in string (' + numSubstitutions + ' so far).');
			}
			var param = arguments[numSubstitutions];
			var pad = '';
						 if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1);
				else if (pPad) pad = pPad;
			var justifyRight = true;
						 if (pJustify && pJustify === "-") justifyRight = false;
			var minLength = -1;
						 if (pMinLength) minLength = parseInt(pMinLength);
			var precision = -1;
						 if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1));
			var subst = param;
						 if (pType == 'b') subst = parseInt(param).toString(2);
				else if (pType == 'c') subst = String.fromCharCode(parseInt(param));
				else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0;
				else if (pType == 'u') subst = Math.abs(param);
				else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param);
				else if (pType == 'o') subst = parseInt(param).toString(8);
				else if (pType == 's') subst = param;
				else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase();
				else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase();
		}
		str = leftpart + subst + rightPart;
	}
	return str;
}


