nitem=0;

function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;
  var objColl = objContElm.getElementsByTagName(strTag);
  if (!objColl.length &&  strTag == "*" &&  objContElm.all) objColl = objContElm.all;
  var arr = new Array();
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';
  var arrClass = strClass.split(delim);
  for (var i = 0, j = objColl.length; i < j; i++) {
    var arrObjClass = objColl[i].className.split(' ');
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (var k = 0, l = arrObjClass.length; k < l; k++) {
      for (var m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]);
          break comparisonLoop;
        }
      }
    }
  }
  return arr;
}

function menuKepCsere(obj,kep)
{
	obj.style.backgroundImage="url(uploaded_files/"+kep+")";
	//obj.firstChild.src="uploaded_files/"+kep;
}

function menuKepCsere2(obj,kep)
{
	obj.style.backgroundImage="url(images/"+kep+")";
	//obj.firstChild.src="uploaded_files/"+kep;
}

function swMenu(id)
{
	menuObj=document.getElementById('almenu_'+id);
	var statusz=menuObj.style.display;

	if ($("#almenu_"+id).is(":hidden"))
	{
		$("#almenu_"+id).slideDown("fast");
	}
	else
	{
		$("#almenu_"+id).slideUp("fast");
	}

}

function swSlider(obj)
{
	var statusz=document.getElementById('slider_container').style.display;
	if ($("#slider_container").is(":hidden"))
	{
		$("#slider_container").slideDown("fast");
		document.getElementById('slider_container').style.display='block';
		obj.src="images/up.gif";
		document.getElementById('hir_lista').style.marginTop='20px';
		filename="scripts/ajax.php?op=setsliderstat&stat=open&ts=" + new Date().getTime();
	}
	else
	{
		$("#slider_container").slideUp("fast");
		obj.src="images/down.gif";
		document.getElementById('hir_lista').style.marginTop='0px';
		filename="scripts/ajax.php?op=setsliderstat&stat=close&ts=" + new Date().getTime();
	}
	ajaxRequest(filename,false);
}

function switchobj(id)
{
	if ($("#"+id).is(":hidden"))
	{
		$("#"+id).slideDown("fast");
	}
	else
	{
		$("#"+id).slideUp("fast");
	}
}

function chPict(mit,mire)
{
	document.getElementById(mit).src=mire;
}

function checkUnique(id)
{
	filename="scripts/ajax.php?op=checkunique&id="+id+"&m="+this.id+"&ts=" + new Date().getTime();
	ajaxRequest(filename,false);
}

function fulHref(obj)
{
	var target=obj.firstChild.href;
	window.location.href=target;
}

var fontSizeMin=11;
var fontSizeMax=16;

if (Get_Cookie('gvkik.hu.fs')>0) var fontSizeDiff=Get_Cookie('gvkik.hu.fs');
else var fontSizeDiff=0;

function incFSize()
{
	if (fontSizeDiff<5)
	{
		var tomb=new Array('a','p','span','td');
		//var tomb=new Array('a');
		for (ii=0;ii<=tomb.length-1;ii++)
		{
			var p = document.getElementsByTagName(tomb[ii]);
			for(i=0;i<p.length;i++) 
			{
				var s=parseInt(getStyle(p[i]));
				//if(s<=fontSizeMax)
				{
					s += 1;
				}
				if (p[i].className!='nc') p[i].style.fontSize = s+"px";
			}
		}
		if(s<=fontSizeMax-fontSizeMin)
		{
			fontSizeDiff++;
			Set_Cookie('gvkik.hu.fs', fontSizeDiff);
		}
	}
}

function decFSize()
{
	if (fontSizeDiff>0)
	{
		var tomb=new Array('a','p','span','td');
		for (ii=0;ii<=tomb.length-1;ii++)
		{
			var p = document.getElementsByTagName(tomb[ii]);
			for(i=0;i<p.length;i++)
			{
				var s=parseInt(getStyle(p[i]));
				//if(s>=fontSizeMin)
				{
					s -= 1;
				}
				if (p[i].className!='nc') p[i].style.fontSize = s+"px";
			}
		}
		if(s!=fontSizeMax-fontSizeMin)
		{
			fontSizeDiff--;
			Set_Cookie('gvkik.hu.fs', fontSizeDiff);
		}
	}
}

function getStyle(el)
{
	if(el.currentStyle)
	return el.currentStyle.fontSize;
	if(document.defaultView)
	{
		return document.defaultView.getComputedStyle(el, '').getPropertyValue("font-size");
	}
}

/*
Script Name: Javascript Cookie Script
Author: Public Domain, with some modifications
Script Source URI: http://techpatterns.com/downloads/javascript_cookies.php
Version 1.1.1
Last Update: 4 October 2007

Changes:
1.1.1 fixes a problem with Get_Cookie that did not correctly handle case
where cookie is initialized but it has no "=" and thus no value, the
Get_Cookie function generates a NULL exception. This was pointed out by olivier, thanks

1.1.0 fixes a problem with Get_Cookie that did not correctly handle
cases where multiple cookies might test as the same, like: site1, site

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
*/

// this fixes an issue with the old method, ambiguous values 
// with this test document.cookie.indexOf( name + "=" );

// To use, simple do: Get_Cookie('cookie_name'); 
// replace cookie_name with the real cookie name, '' are required
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;
	}
}

/*
only the first 2 parameters are required, the cookie name, the cookie
value. Cookie time is in milliseconds, so the below expires will make the 
number you pass in the Set_Cookie function call the number of days the cookie
lasts, if you want it to be hours or minutes, just get rid of 24 and 60.

Generally you don't need to worry about domain, path or secure for most applications
so unless you need that, leave those parameters blank in the function call.
*/
function Set_Cookie( name, value, expires, path, domain, secure ) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	// if the expires variable is set, make the correct expires time, the
	// current script below will set it for x number of days, to make it
	// for hours, delete * 24, for minutes, delete * 60 * 24
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	//alert( 'today ' + today.toGMTString() );// this is for testing purpose only
	var expires_date = new Date( today.getTime() + (expires) );
	//alert('expires ' + expires_date.toGMTString());// this is for testing purposes only

	document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
		( ( path ) ? ";path=" + path : "" ) +
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function checkFSize()
{
	var fs=parseInt(Get_Cookie('gvkik.hu.fs'));

	if (fs>0)
	{
		var tomb=new Array('a','p','span','td');
		for (ii=0;ii<=tomb.length-1;ii++)
		{
			var p = document.getElementsByTagName(tomb[ii]);
			for(i=0;i<p.length;i++) {
				var s=parseInt(getStyle(p[i]));
				if(s!=fontSizeMax) {
					s=s+fs;
				}
				if (p[i].className!='nc') p[i].style.fontSize = s+"px";
	   		}
		}
	}
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

/************************************************************************************************************
(C) www.dhtmlgoodies.com, October 2005

This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	

Updated:	
	March, 11th, 2006 - Fixed positioning of tooltip when displayed near the right edge of the browser.
	April, 6th 2006, Using iframe in IE in order to make the tooltip cover select boxes.
	
Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.

Thank you!

www.dhtmlgoodies.com
Alf Magne Kalleland

************************************************************************************************************/	
var dhtmlgoodies_tooltip = false;
var dhtmlgoodies_tooltipShadow = false;
var dhtmlgoodies_shadowSize = 4;
var dhtmlgoodies_tooltipMaxWidth = 800;
var dhtmlgoodies_tooltipMinWidth = 100;
var dhtmlgoodies_iframe = false;
var tooltip_is_msie = (navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('opera')==-1 && document.all)?true:false;
function showTooltip(e,tooltipTxt)
{
	
	var bodyWidth = Math.max(document.body.clientWidth,document.documentElement.clientWidth) - 20;

	if(!dhtmlgoodies_tooltip){
		dhtmlgoodies_tooltip = document.createElement('DIV');
		dhtmlgoodies_tooltip.id = 'dhtmlgoodies_tooltip';
		dhtmlgoodies_tooltipShadow = document.createElement('DIV');
		dhtmlgoodies_tooltipShadow.id = 'dhtmlgoodies_tooltipShadow';
		
		document.body.appendChild(dhtmlgoodies_tooltip);
		document.body.appendChild(dhtmlgoodies_tooltipShadow);	
		
		if(tooltip_is_msie){
			dhtmlgoodies_iframe = document.createElement('IFRAME');
			dhtmlgoodies_iframe.frameborder='5';
			dhtmlgoodies_iframe.style.backgroundColor='#FFFFFF';
			dhtmlgoodies_iframe.src = '#'; 	
			dhtmlgoodies_iframe.style.zIndex = 100;
			dhtmlgoodies_iframe.style.position = 'absolute';
			document.body.appendChild(dhtmlgoodies_iframe);
		}
		
	}
	
	dhtmlgoodies_tooltip.style.display='block';
	dhtmlgoodies_tooltipShadow.style.display='block';
	if(tooltip_is_msie)dhtmlgoodies_iframe.style.display='block';
	
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	//if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0;
	var leftPos = e.clientX + 10;
	
	dhtmlgoodies_tooltip.style.width = null;	// Reset style width if it's set 
	dhtmlgoodies_tooltip.innerHTML = tooltipTxt;
	dhtmlgoodies_tooltip.style.left = leftPos + 'px';
	dhtmlgoodies_tooltip.style.top = e.clientY + 10 + st + 'px';

	
	dhtmlgoodies_tooltipShadow.style.left =  leftPos + dhtmlgoodies_shadowSize + 'px';
	dhtmlgoodies_tooltipShadow.style.top = e.clientY + 10 + st + dhtmlgoodies_shadowSize + 'px';
	
	if(dhtmlgoodies_tooltip.offsetWidth>dhtmlgoodies_tooltipMaxWidth){	/* Exceeding max width of tooltip ? */
		dhtmlgoodies_tooltip.style.width = dhtmlgoodies_tooltipMaxWidth + 'px';
	}
	
	var tooltipWidth = dhtmlgoodies_tooltip.offsetWidth;		
	if(tooltipWidth<dhtmlgoodies_tooltipMinWidth)tooltipWidth = dhtmlgoodies_tooltipMinWidth;
	
	
	dhtmlgoodies_tooltip.style.width = tooltipWidth + 'px';
	dhtmlgoodies_tooltipShadow.style.width = dhtmlgoodies_tooltip.offsetWidth + 'px';
	dhtmlgoodies_tooltipShadow.style.height = dhtmlgoodies_tooltip.offsetHeight + 'px';		
	
	if((leftPos + tooltipWidth)>bodyWidth){
		dhtmlgoodies_tooltip.style.left = (dhtmlgoodies_tooltipShadow.style.left.replace('px','') - ((leftPos + tooltipWidth)-bodyWidth)) + 'px';
		dhtmlgoodies_tooltipShadow.style.left = (dhtmlgoodies_tooltipShadow.style.left.replace('px','') - ((leftPos + tooltipWidth)-bodyWidth) + dhtmlgoodies_shadowSize) + 'px';
	}
	
	if(tooltip_is_msie){
		dhtmlgoodies_iframe.style.left = dhtmlgoodies_tooltip.style.left;
		dhtmlgoodies_iframe.style.top = dhtmlgoodies_tooltip.style.top;
		dhtmlgoodies_iframe.style.width = dhtmlgoodies_tooltip.offsetWidth + 'px';
		dhtmlgoodies_iframe.style.height = dhtmlgoodies_tooltip.offsetHeight + 'px';
	
	}
			
}

function hideTooltip()
{
	dhtmlgoodies_tooltip.style.display='none';
	dhtmlgoodies_tooltipShadow.style.display='none';		
	if(tooltip_is_msie)dhtmlgoodies_iframe.style.display='none';		
}

//this shows an element
function Show(theElement)	{
	var elem = document.getElementById(theElement) ;
	if ( elem ) {
		elem.style.display = "" ;
	}
}
//this hdes an element
function Hide(theElement)	{
	var elem = document.getElementById(theElement) ;
	if ( elem ) {
		elem.style.display = "none" ;
	}
}
//this shows or hides an element depending of Show is true or false
function ShowHideElement ( ElementID, Showit ) {
	if( Showit ){
		Show( ElementID );
	} else {
		 Hide( ElementID );
	}
}
//this function checks all 
function CheckAll(){
	for( i=1;i<=5; i++ ) {	
		Hide ( "Table_"+i);
	}
}
//this will show the div for the select box value
function ShowHideWhichbook( value ){
	HideWhichbook();			
	switch ( value.toString() ) {
		case "0":
		case "1":
		case "2":
			Show( "whichbook_" + value.toString() );				
			break;
	}
}
//hide all whichbok divs
function HideWhichbook() {
	for( i=1;i<=3;i++ ) {
		Hide("whichbook_" + i);
	}
}

function getDetails(url,gnitem)
{
	//var nitem=0;
	ertekek=new Array();
	ertekek=url.split('=');
	index=ertekek.length-1;
	//nitem=ertekek[index];
	nitem=gnitem;
	ajaxCallback=showDetails;
	filename="cgi-bin/egyszeru4.exe"+url;
	ajaxRequest(filename,true);
}

function showDetails()
{
	result=ajaxreq.responseText;
	parts=result.split('<tr>');
	var out='';
	jQuery.each(parts,function(index,value)
	{
		if (value.search('<td></td>')==-1) out+=value;

  });
	var elvalasztok=new Array();
	elvalasztok=getElementsByClassName('elvalasztok');
	
	while (!document.getElementById('elvalaszto'+nitem))
	{
		nitem++;
	}

	document.getElementById('elvalaszto'+nitem).style.display='none';
	$("#details"+nitem).slideUp("fast");
	document.getElementById('details'+nitem).innerHTML='<p style="text-align:right; font-weight:bold; margin-bottom:0px;"><span style="cursor:pointer;" onclick="closeDetails('+nitem+');">X</span></p>'+out;
	$("#details"+nitem).slideDown("fast");

}

function closeDetails(id)
{
	$("#details"+id).slideUp("fast");
	document.getElementById('elvalaszto'+id).style.display='block';
}

function manCal()
{
	var calFrame = document.getElementById('gcalendar');
	if ( calFrame.contentDocument ) { // DOM
	    //var form = iframeEl.contentDocument.getElementById('ifrmTest');
	    //var events=calFrame.contentDocument.getElementsByClassName('te-s');
	    var divid=calFrame.contentDocument.getElementById('container');
	} else if ( iframeEl.contentWindow ) { // IE win
	    //var form = iframeEl.contentWindow.document.getElementById('ifrmTest');
	    //var events=calFrame.contentWindow.document.getElementsByClassName('te-s');
	    var divid=calFrame.contentWindow.document.getElementById('container');
	}

	alert (calFrame);
}

function doNext(id)
{
	ajaxCallback=chRef;
	id=document.getElementById('konyvajanlo_id').value;
	filename="include/panelek/konyvajanlo.php?ret=1&id="+id+"&lang="+lang+"&ts=" + new Date().getTime();
	ajaxRequest(filename,true);
}

function chRef()
{
        result=ajaxreq.responseText;
        document.getElementById('konyvajanlo').innerHTML=result;
        id=document.getElementById('zenei_ajanlo_id').value;

	ajaxCallback=chRefZ;
	filename="include/panelek/zenei_ajanlo.php?ret=1&id="+id+"&lang="+lang+"&ts=" + new Date().getTime();
	ajaxRequest(filename,true);
}

function chRefZ()
{
        result=ajaxreq.responseText;
        document.getElementById('zenei_ajanlo').innerHTML=result;
        id=document.getElementById('konyvajanlo_id').value;
        setTimeout("doNext("+id+")",10000);
	//setTimeout("doNextZ("+id+")",10000);
}

