  $(document).ready( function() {						  	
	  $('a.tovabb_gomb').each ( function(key, value) { 
		$(this).mouseover( function(e) {
			$(this).find("img").attr('src', '/gfx/tovabb_gomb-1.gif');
		})
	  });
	  $('a.tovabb_gomb').each ( function(key, value) { 
		$(this).mouseout( function(e) {
			$(this).find('img').attr('src', '/gfx/tovabb_gomb.gif');
		})
	  });	 
  });


 var ie = document.all ? 1 : 0;
  var ns = document.layers ? 1 : 0;


    function getObj(name) {
    if (document.getElementById) {
      return document.getElementById(name);
    } else if (document.all) {
      return document.all[name];
    } else if (document.layers) {
      return document.layers[name];
    }
    else return false;
  }
 
  function loading_show() {
	var obj = getObj('div_loading');
	if (obj) {
		obj.className='loading-visible';
	}
  }
  function loading_hide() {
	var obj = getObj('div_loading');
	if (obj) {
		obj.className='loading-invisible';
	}
  }
    
	function getBrowserHeight() {
		var intH = 0;
		var intW = 0;
		if(typeof window.innerWidth  == 'number') {
			intH = window.innerHeight;
			intW = window.innerWidth;
		} else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
			intH = document.documentElement.clientHeight;
			intW = document.documentElement.clientWidth;
		} else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
			intH = document.body.clientHeight;
			intW = document.body.clientWidth;
		}
		return {width: parseInt(intW), height: parseInt(intH)};
	}
	function SetLayerPosition() {
		var o_bws = getBrowserHeight(); 	   
		var o_elem = getObj("div_loading"); 
		var o_info = getObj("w_info");   
		if (o_elem) {
			//var scrollX = parseInt( (o_bws.width-200)/2 + document.body.scrollLeft );
			//var scrollY = parseInt( (200)/2 + document.body.scrollTop );
			var scrollY = parseInt( (o_bws.height- o_elem.offsetHeight)/2 + document.body.scrollTop );
			var scrollX = parseInt( (o_bws.width-200)/2 + document.body.scrollLeft );
			o_elem.style.left = ( scrollX ) + "px";
			o_elem.style.top = ( scrollY )  + "px"; 
			if (o_info) o_info.value = (o_bws.width)/2 + " | " + o_elem.offsetHeight ;
		}
		elem = null;
	}


	function cw_onresize() {
		SetLayerPosition();
	}	
	function cw_onscroll() {
		SetLayerPosition();
	}
	function cw_onload() {
		SetLayerPosition();
	}

	window.onbeforeunload = loading_show;
	window.onresize	= cw_onresize;
	window.onscroll	= cw_onscroll;
	window.onload 	= cw_onload;


	Date.prototype.addMinute = function(n) {
		this.setMinutes(this.getMinutes()+n);
		return this;
	};
	Date.prototype.addDay = function(n) {
		this.setDate(this.getDate()+n);
		//this.setTime(this.getTime()+(n*86400000));
		return this;
	};
	
	
	function set_date_obj (objid, n) {
		var obj = getObj(objid);
		arr = obj.value.split(/\D+/);
		//sy = 1*obj.value.substring(0,4);
		//sm = 1*obj.value.substring(5,7);
		//sd = 1*obj.value.substring(8,10);
		sy = arr[0];
		sm = (arr[1]-1);
		sd = arr[2]*1;
	
		var d = new Date(sy,sm,sd);
		d.addDay(n);
		
		//alert (sy+"-"+sm+"-"+sd+" | " +d.getFullYear()+"-"+d.getMonth()+"-"+d.getDate());
	
		sy = d.getFullYear();
		sm = (d.getMonth()+1);
		sd = d.getDate();
		if (sm<10) sm = "0"+sm;
		if (sd<10) sd = "0"+sd;
	
		obj.value = sy+"-"+sm+"-"+sd;
	}
	
	
	
	function isDate (y, m, d) { //v1.0
			if(typeof y == "string" && m instanceof RegExp && d){
				if(!m.test(y)) return 1;
				y = RegExp["$" + d.y], m = RegExp["$" + d.m], d = RegExp["$" + d.d];
			}
			d = Math.abs(d) || 0, m = Math.abs(m) || 0, y = Math.abs(y) || 0;
			return arguments.length != 3 ? 1 : d < 1 || d > 31 ? 2 : m < 1 || m > 12 ? 3 : /4|6|9|11/.test(m) && d == 31 ? 4
			: m == 2 && (d > ((y = !(y % 4) && (y % 1e2) || !(y % 4e2)) ? 29 : 28)) ? 5 + !!y : 0;
	};
	
	function is_valid_ymd (str) {
 		return !isDate(str, /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/, {d: 3, m: 2, y: 1});
	}
	
	function is_date_between (d, s, b) {
		var t_d = new Date( d.replace(/-/gi,"/") );
		var t_s = new Date( s);
		var t_b = new Date( b );
		if (t_s<t_b) {
			x = (t_d>t_s); y = (t_d<t_b);
		} else {
			x = (t_d>t_b); y = (t_d<t_s);
		}				
		return  x && y;
	}

	function is_valid_email (email) {
	   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	   if(reg.test(email) == false) {
		  return false;
	   }
	   return true;
	}
		
	function addLoadEvent(func) { 
		var oldonload = window.onload; 
		if (typeof window.onload != 'function'){ 
			window.onload = func
		} else { 
			window.onload = function() {
				oldonload();
				func();
			}
		}
	}//


/* ########################## */

	function sel_a2b(a_name,b_name) {
		var a = getObj(a_name);
		var b = getObj(b_name);
		if (!a || !b) return;
		a_len = a.length ;
		for ( i=0; i<a_len ; i++){
			if (a.options[i].selected == true ) {
				b_len = b.length;
				b.options[b_len]= new Option(a.options[i].text,a.options[i].value);
			}
		}
		for ( i = (a_len -1); i>=0; i--){
			if (a.options[i].selected == true ) {
				a.options[i] = null;
			}
		}	
	}//
	function sel_up(o_name) {
		var obj = getObj (o_name);
		if (!obj) return;
		var currernt;
		var reverse;
		if(obj.options[obj.options.selectedIndex].index > 0) {
			sel_swap (obj.options[obj.options.selectedIndex], obj.options[obj.options.selectedIndex - 1]);
			self.focus();
			obj.options.selectedIndex--;
		}
	}//
	function sel_down(o_name) {
		var obj = getObj(o_name);
		if (!obj) return;
		if(obj.options[obj.options.selectedIndex].index != obj.length-1) {
			sel_swap (obj.options[obj.options.selectedIndex], obj.options[obj.options.selectedIndex + 1]);
			self.focus();
			obj.options.selectedIndex++;
		}
	}//
	function sel_swap (oa,ob) {
		var tmp_value = "";	var tmp_text = "";
		tmp_value = oa.value; 	tmp_text = oa.text;
		oa.value = ob.value; 	oa.text = ob.text;
		ob.value = tmp_value;	ob.text = tmp_text;
	}//
	function sel_all_options (oname) {
		var obj = getObj(oname);
		if (obj) {
			for ( i=0; i<obj.length ; i++){
				obj.options[i].selected = true;
			}
		}
		return true;
	}//

/* ########################## */

	function disableObj (id,b) {
		//alert (name + '\n' + b);
		var o = getObj(id);
		if (o) { o.disabled = b; }
	}
	

	var arr_menus = new Array();

	function showsubmenu(id){
		for(i=0;i<arr_menus.length;i++){
			sid = arr_submenus[i];
			menu=getObj('nav_'+sid);
			submenu=getObj('s_'+sid);		
			if(sid==id){
				if (submenu) { submenu.style.display="block"; }
				if (menu) {
						menu.className=menu.className.replace(new RegExp(" nav_unsel"), "");
						menu.className=menu.className + ' nav_sel';
				}
			} else{
				if (submenu) { submenu.style.display="none"; }
				if (menu) {
					menu.className=menu.className.replace(new RegExp(" nav_sel\\b"), "nav_unsel");
				}
			}
		}
	} 

	function calcHeight(elem) {
	  getObj('ifr_form').style.height = (elem.offsetHeight)+'px';
	}


	function showProps(obj, objName) { 
		if (typeof(objName) == "undefined") objName = "object"; 
		var result = ""; 
		for (var i in obj) { 
			result += objName + "." + i + " = "; 
			try { 
				result += obj[i]; 
			} catch (e) { 
				result += e; 
			} 
			result += "\n"; 
		} 
		var w = window.open("", "w", "width=560,height=450,resizable=yes,scrollbars=yes"); 
		w.document.write("<pre>" + result + "</pre>"); 
		w.document.close(); 
	}

   function getp(obj) {
   		if (obj) {
		  var getstr = "?";
		  for (i=0; i<obj.childNodes.length; i++) {
			 if (obj.childNodes[i].tagName == "INPUT") {
				if (obj.childNodes[i].type == "hidden") {
				   getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
				}
				if (obj.childNodes[i].type == "text") {
				   getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
				}
				if (obj.childNodes[i].type == "checkbox") {
				   if (obj.childNodes[i].checked) {
					  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
				   } else {
					  getstr += obj.childNodes[i].name + "=&";
				   }
				}
				if (obj.childNodes[i].type == "radio") {
				   if (obj.childNodes[i].checked) {
					  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
				   }
				}
			 }   
			 if (obj.childNodes[i].tagName == "SELECT") {
				var sel = obj.childNodes[i];
				getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
			 }
			 
		  }
		  return getstr;
		}
   }
   
   function frm_send (objid) {
   		var obj = getObj(objid);
   		if (obj) {
			showProps (obj,obj);
			alert (getp(obj));
   			xh_result ('xh_result_frm', '/dvh_xh_form.php', getp(obj));
		}else {
   			xh_result ('xh_result_frm', '/dvh_xh_form.php', '');
		}
   }


// Simulates PHP's date function
Date.prototype.format = function(format) {
	var returnStr = '';
	var replace = Date.replaceChars;
	for (var i = 0; i < format.length; i++) {
		var curChar = format.charAt(i);
		if (i - 1 >= 0 && format.charAt(i - 1) == "\\") { 
			returnStr += curChar;
		}
		else if (replace[curChar]) {
			returnStr += replace[curChar].call(this);
		} else if (curChar != "\\"){
			returnStr += curChar;
		}
	}
	return returnStr;
};
 
Date.replaceChars = {
	shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
	longMonths: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
	shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
	longDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
	
	// Day
	d: function() { return (this.getDate() < 10 ? '0' : '') + this.getDate(); },
	D: function() { return Date.replaceChars.shortDays[this.getDay()]; },
	j: function() { return this.getDate(); },
	l: function() { return Date.replaceChars.longDays[this.getDay()]; },
	N: function() { return this.getDay() + 1; },
	S: function() { return (this.getDate() % 10 == 1 && this.getDate() != 11 ? 'st' : (this.getDate() % 10 == 2 && this.getDate() != 12 ? 'nd' : (this.getDate() % 10 == 3 && this.getDate() != 13 ? 'rd' : 'th'))); },
	w: function() { return this.getDay(); },
	z: function() { var d = new Date(this.getFullYear(),0,1); return Math.ceil((this - d) / 86400000); }, // Fixed now
	// Week
	W: function() { var d = new Date(this.getFullYear(), 0, 1); return Math.ceil((((this - d) / 86400000) + d.getDay() + 1) / 7); }, // Fixed now
	// Month
	F: function() { return Date.replaceChars.longMonths[this.getMonth()]; },
	m: function() { return (this.getMonth() < 9 ? '0' : '') + (this.getMonth() + 1); },
	M: function() { return Date.replaceChars.shortMonths[this.getMonth()]; },
	n: function() { return this.getMonth() + 1; },
	t: function() { var d = new Date(); return new Date(d.getFullYear(), d.getMonth(), 0).getDate() }, // Fixed now, gets #days of date
	// Year
	L: function() { var year = this.getFullYear(); return (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)); },	// Fixed now
	o: function() { var d  = new Date(this.valueOf());  d.setDate(d.getDate() - ((this.getDay() + 6) % 7) + 3); return d.getFullYear();}, //Fixed now
	Y: function() { return this.getFullYear(); },
	y: function() { return ('' + this.getFullYear()).substr(2); },
	// Time
	a: function() { return this.getHours() < 12 ? 'am' : 'pm'; },
	A: function() { return this.getHours() < 12 ? 'AM' : 'PM'; },
	B: function() { return Math.floor((((this.getUTCHours() + 1) % 24) + this.getUTCMinutes() / 60 + this.getUTCSeconds() / 3600) * 1000 / 24); }, // Fixed now
	g: function() { return this.getHours() % 12 || 12; },
	G: function() { return this.getHours(); },
	h: function() { return ((this.getHours() % 12 || 12) < 10 ? '0' : '') + (this.getHours() % 12 || 12); },
	H: function() { return (this.getHours() < 10 ? '0' : '') + this.getHours(); },
	i: function() { return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes(); },
	s: function() { return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds(); },
	u: function() { var m = this.getMilliseconds(); return (m < 10 ? '00' : (m < 100 ? '0' : '')) + m; },
	// Timezone
	e: function() { return "Not Yet Supported"; },
	I: function() { return "Not Yet Supported"; },
	O: function() { return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + '00'; },
	P: function() { return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + ':00'; }, // Fixed now
	T: function() { var m = this.getMonth(); this.setMonth(0); var result = this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/, '$1'); this.setMonth(m); return result;},
	Z: function() { return -this.getTimezoneOffset() * 60; },
	// Full Date/Time
	c: function() { return this.format("Y-m-d\\TH:i:sP"); }, // Fixed now
	r: function() { return this.toString(); },
	U: function() { return this.getTime() / 1000; }
};


function NewWindow(mypage,myname,w,h,scroll){
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	var settings ='height='+h+',';
	settings +='width='+w+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='scrollbars='+scroll+',';
	settings +='resizable=yes,toolbar=0,status=0,';
	wnd=window.open(mypage,myname,settings);
	if(parseInt(navigator.appVersion) >= 4){wnd.window.focus();}
}  
