var auto_suggest = false;

//map popup
var fw=760
var fh=550
if (window.screen) {
   fw = window.screen.availWidth-40;
   fh = window.screen.availHeight-80;
}

//auto suggest
$(document).ready(function(){
	if(document.getElementById('raktiniai_pataria') && auto_suggest){
		var options_xml = {
			script:URL+"imones/paieskos_forma_pataria.php?kalba="+LANGUAGE+"&",
			varname:"id"
		};
		var as_xml = new AutoSuggest('raktiniai_pataria', options_xml);
	}
	//fokusuojam
	$("#raktiniai_pataria").focus();
});


//dynamic js loading
function include_js(path_js, callback){
  var script = document.createElement("script");
  script.src = path_js;
  script.type = "text/javascript";
  document.getElementsByTagName("head")[0].appendChild(script);
  
  if(callback){
		// Firefox
		script.onload = function() {
			eval(callback + "();");
		}
		
		// IE
		script.onreadystatechange = function() {
			if (/loaded|complete/.test(this.readyState)) {
			  eval(callback + "();");
			}
		}
  }


}

function print_r(theObj){ 
	output = '';
	if(theObj.constructor == Array || theObj.constructor == Object){ 
	  //document.write("<ul>")
	  output += "\t\n";
	  for(var p in theObj){ 
		 if(theObj[p].constructor == Array || theObj[p].constructor == Object){ 
			//document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
			output += "["+p+"] => "+typeof(theObj)+"\n";
			//document.write("<ul>") 
			output += "\t\n";
			print_r(theObj[p]); 
			//document.write("</ul>") 
		 } else { 
			//document.write("<li>["+p+"] => "+theObj[p]+"</li>");
			output += "["+p+"] => "+theObj[p]+"\n";
		 } 
	  } 
	  //document.write("</ul>") 
	  return output;
	}
	return false;
}


//jquery plugin clear form
/*
$.fn.clearForm = function() {
  return this.each(function() {
 var type = this.type, tag = this.tagName.toLowerCase();
 if (tag == 'form')
   return $(':input',this).clearForm();
 if (type == 'text' || type == 'password' || tag == 'textarea')
   this.value = '';
 else if (type == 'checkbox' || type == 'radio')
   this.checked = false;
 else if (tag == 'select')
   this.selectedIndex = -1;
  });
};
*/

$(document).ready(function(){
	//firm page direction swap
	if($("#map_firm_info_direction_form").length){
		$("#map_firm_info_direction_form #direction_swap").click(function () {
			temp = $("#search_direction_start").attr("value");
			$("#search_direction_start").attr("value", $("#search_direction_end").attr("value"));
			$("#search_direction_end").attr("value", temp);
		});
	}
	if($("#map_firm_info_popup").length){
		$("#map_firm_info_popup").click(function () {
			window.open(this.href,'','left=20,top=20,width='+fw+',height='+fh+',toolbar=0,resizable=1,scrollbars=0,');
			return false;
		});
	}
});


