function isObject(id){
	 if(document.getElementById(id)){
		 return true;
	 } else {
		return false;
	};
}

function initSmoothMenu(menuid,cls) {
	if (isObject(menuid) == true) {
		ddsmoothmenu.init({
			mainmenuid: menuid, //menu DIV id
			orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
			classname: cls, //class added to menu's outer DIV
			//customtheme: ["#1c5a80", "#18374a"],
			contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
		})
		
	};
}

function initFileButt(id) {

if (isObject(id) == true) {
      $("input."+id).filestyle({ 
          image: "../jquery/choose-file.gif",
          imageheight : 22,
          imagewidth : 82,
          width : 50
      });  
	  
}
	  

}

function initEditForm(id){
if (isObject(id) == true) {
	
	$.validator.methods.equal = function(value, element, param) {
		return value == param;
	};	
	
	$("#"+id).validate({
		success: function(label) {
				label.text("").addClass("success");
			},
		rules: {
				math: {
					equal: document.getElementById("valValue").value	
				}
		},
		messages: {
			math: {
				equal: "Vložte správný výsledek",
			}
		}
	});
}
}

function openSBox (){
    Shadowbox.open({
        content:    '<div id="welcome-msg">Welcome to my website!</div>',
        title:      "Welcome",
        height:     350,
        width:      350
    });

}


$(document).ready(function(){
						   
	initSmoothMenu('smoothmenu1','ddsmoothmenu');
	//initFileButt("filex");
	initEditForm("myForm");
	/*$("#bcTarget").barcode("9934567890128", "ean13");  */  
	
	// second example


});

soundManager.url = '../soundmanager/';

soundManager.onload = function() {
// SM2 has loaded - now you can create and play sounds!
//soundManager.createSound('helloWorld','http://www.voltage.cz/cz/storage/markof/download/200912301119_02-From-Rino.mp3');
//soundManager.play('helloWorld');
}

function playSound(sound,name) {
	soundManager.createSound(name,sound);
	soundManager.play(name);  
}

hs.graphicsDir = '../highslide/graphics/';
hs.align = 'center';
hs.outlineType = 'glossy-dark';
hs.wrapperClassName = 'dark';

//hs.outlineType = 'rounded-white';
//hs.wrapperClassName = 'white';
hs.dimmingOpacity = 0.5;

hs.Expander.prototype.onAfterExpand = function() { 
//document.documentElement.style.overflow = "hidden"; 
}

 hs.Expander.prototype.onAfterClose = function() { 
   document.documentElement.style.overflow = "auto";
}

 function refreshHs() {
 window.location = window.location.href;
 }
 
 function showSaving(content) {
	 //hs.htmlExpand(null, {maincontentText: content, dimmingOpacity:1, dimmingDuration:0, outlineType:null } );

 }
 
 function redirectPage(loc) {

 window.location = loc;
 } 
 
  function closeHs() {
 parent.window.hs.close();
 }
 
  function loadContent(where,what){
	time = 200;

	halftime = (time/2)/1000;
	$("#"+where).html('<div style="background-color:black; padding:10px; color:#999999;"><img src="system/img/ajax-loader-black.gif"> Čekejte, nahrávám data.</div>');
	$("#"+where).load(what);
 }
 
 
 function showButt(element) {
          var div = document.getElementById(element);
          div.style.visibility = "visible";
          div.style.display = "block";
          div.top = "50";
          div.left = "50";
}

 
function closeButt(element) {
         var div = document.getElementById(element);
         div.style.visibility = "hidden";
         div.style.display = "none";
}

function formCallback(result, form) {
	window.status = "valiation callback for form '" + form.id + "': result = " + result; }
	

 function hideScrollbar() {
 parent.document.documentElement.style.overflow = "hidden";
 document.documentElement.style.overflow = "auto";

 
 }


function Smazat(url) {
if (confirm('Opravdu smazat?')) {location.href=url;return true;
}else{return false;}
}

function objGet(x) {
   if (typeof x != 'string') return x;
   else if (Boolean(document.getElementById))
      return document.getElementById(x);
   else if (Boolean(document.all))
      return eval('document.all.'+x);
   else if (Boolean(document.ids))
      return eval('document.ids.'+x);
   else
      return null;
}


  function DoNav(theUrl)
  {
  document.location.href = theUrl;
  }
  

var map = null;
var geocoder = null;

function load() {

if (GBrowserIsCompatible()) {
	map = new GMap2(document.getElementById("map"));
	geocoder = new GClientGeocoder();
	map.addControl(new GSmallMapControl());

	
	}
	var address = document.getElementById("address").value; 
	if (geocoder) {
	geocoder.getLatLng(
	address,
		function(point) {
			if (!point) {
			alert(address + " not found");
			} else {
			map.setCenter(point, 7);
			var marker = new GMarker(point);
			map.addOverlay(marker);
			/*marker.openInfoWindowHtml(address);*/
			}
		}
	);
	
}
}




function checkTree(){
  if(document.getElementById("mainTree")){
	treeObj = new DHTMLSuite.JSDragDropTree();
	treeObj.setTreeId('mainTree');
	treeObj.init();
	};
}
