// JavaScript Document


<!-- ============================	-->
<!-- SAJÁT VEZÉRLŐ SCRIPT-EK		-->
	function smartinput(element,mode,hide)
	{
		switch (mode)
		{
			case 'focus':	if ( element.value == element.alt ) { element.value = ''; element.className = 'input'; if ( hide==1 ) { element.type = 'password'; } }
			// element.className = element.className.replace(' dummy',''); }
			Log_JS('element.alt='+element.alt+', element.value='+element.value);
			break;
			
			case 'blur':	if ( element.value == '' ) { element.value = element.alt; element.className = 'dummy'; if ( hide==1 ) { element.type = 'text'; } }
			Log_JS('element.alt='+element.alt+', element.value='+element.value);
			break;
	
			case 'reset':	elements = element.split(';');
							
							for (i=0;i<elements.length;i++)
							{
								document.getElementById(elements[i]).className = 'dummy';
								if ( document.getElementById(elements[i]).type == 'password') { document.getElementById(elements[i]).type = 'text'; }
								document.getElementById(elements[i]).value = document.getElementById(elements[i]).alt;
							}
			break;
		}
	}


// Kiírással kapcsolatos függvények
//	----------------------------------

	function leadingzeros(melyikSZAM,mennyi)
	{
		if (mennyi > 10) { mennyi = 10; };						// 4
		hossz		= melyikSZAM.length;						// "123" -> 3
		numbers		= '0000000000';
		lz 			= numbers.substring(0,(mennyi-hossz));		// 0000, 4-3 = 1
		return lz + melyikSZAM;
	}



// Gombok kezelése
// ---------------
	// Nagyon nagy gomb

	function buttonXLpressed(obj)
	{
		$('#'+obj).removeClass('buttonXLHL') .addClass('buttonXLpressed');
		$('#'+obj).removeClass('buttonXL') .addClass('buttonXLpressed');
		setTimeout(function(){ $('#'+obj).removeClass('buttonXLpressed') .addClass('buttonXL'); }, 600); 		
 	}

	// Nagy gomb
	function buttonLpressed(obj)
	{
		$('#'+obj).removeClass('buttonLHL') .addClass('buttonLpressed');
		$('#'+obj).removeClass('buttonL') .addClass('buttonLpressed');
		setTimeout(function(){ $('#'+obj).removeClass('buttonLpressed') .addClass('buttonL'); }, 600); 		
	}

	function buttonLnegpressed(obj)
	{
		$('#'+obj).removeClass('buttonLnegHL') .addClass('buttonLnegpressed');
		$('#'+obj).removeClass('buttonLneg') .addClass('buttonLnegpressed');
		setTimeout(function(){ $('#'+obj).removeClass('buttonLnegpressed') .addClass('buttonLneg'); }, 600); 		
	}
	// Kozepes gomb
	function buttonMpressed(obj)
	{
		$('#'+obj).removeClass('buttonMHL') .addClass('buttonMpressed');
		$('#'+obj).removeClass('buttonM') .addClass('buttonMpressed');
		setTimeout(function(){ $('#'+obj).removeClass('buttonMpressed') .addClass('buttonM'); }, 600); 		
	}


// RemoveHyphens
// ----------
	function removeHyphens(szoveg)
	{
		hyphen = String.fromCharCode(194);
		szoveg = szoveg.replace(hyphen,"");	
		szoveg = szoveg.replace(/­/gi,"");
		return szoveg;
	}


// GetElementsByClassname

document.getElementsByClassName = function(cl) 
{
	var retnode = [];
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = this.getElementsByTagName('*');
	for (var i = 0; i < elem.length; i++) 
	{
		var classes = elem[i].className;
		if (myclass.test(classes)) retnode.push(elem[i]);
	}
	return retnode;
};



// Rögzítés Cookie-ban
// --------------------------------------------------------------------------------------------------------------
function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );
  if ( exp_y ) { var expires = new Date ( exp_y, exp_m, exp_d ); cookie_string += "; expires=" + expires.toGMTString() }
  if ( path ) { cookie_string += "; path=" + escape ( path ) }
  if ( domain ) { cookie_string += "; domain=" + escape ( domain ) }
  if ( secure ) { cookie_string += "; secure" }
  document.cookie = cookie_string;
}
// Beolvasás Cookie-ból
// --------------------------------------------------------------------------------------------------------------
function get_cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}			


// Keresés egy tömbön belül
function indexInArray(searchinarray,searchingforthisvalue)
{
	for(var a=0;a<searchinarray.length;a++) if(searchinarray[a]==searchingforthisvalue) return a;
	return -1;
}


// PHP LIBRARY
// ------------
	// DATE
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(replace[curChar]){returnStr+=replace[curChar].call(this);}else{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'],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(){return"Not Yet Supported";},W:function(){return"Not Yet Supported";},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(){return"Not Yet Supported";},L:function(){return(((this.getFullYear()%4==0)&&(this.getFullYear()%100!=0))||(this.getFullYear()%400==0))?'1':'0';},o:function(){return"Not Supported";},Y:function(){return this.getFullYear();},y:function(){return(''+this.getFullYear()).substr(2);},a:function(){return this.getHours()<12?'am':'pm';},A:function(){return this.getHours()<12?'AM':'PM';},B:function(){return"Not Yet Supported";},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();},e:function(){return"Not Yet Supported";},I:function(){return"Not 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))+':'+(Math.abs(this.getTimezoneOffset()%60)<10?'0':'')+(Math.abs(this.getTimezoneOffset()%60));},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;},c:function(){return this.format("Y-m-d")+"T"+this.format("H:i:sP");},r:function(){return this.toString();},U:function(){return this.getTime()/1000;}};
	

