﻿var napok = new Array();
napok[1] = 31;
napok[2] = 28;
napok[3] = 31;
napok[4] = 30;
napok[5] = 31;
napok[6] = 30;
napok[7] = 31;
napok[8] = 31;
napok[9] = 30;
napok[10] = 31;
napok[11] = 30;
napok[12] = 31;


function honap_napok( pEv, pHo, pNap, pPluszNap, pEv2, pHo2, pNap2, pHivo )
{
	var napokszama = 0;
	
	if( pHo.value == 2 && pEv.value % 4 == 0 && pEv.value % 100 != 0 )
	{
		napokszama = 29;
	}
	else
	{
		napokszama = napok[pHo.value];
	}
	
	pNap.length = 0;
	for( i=0; i<napokszama; i++ )
	{
		pNap.options[ i ] = new Option( i+1, i+1 );
	}

/*
	if (pPluszNap != null) 
	{
	    pPluszNap = pPluszNap * 1000 * 60 * 60 * 24;

	    var dIg = new Date(pEv.value, pHo.value - 1, pNap.value);
	    dIg.setDate(dIg.getTime() + pPluszNap);
	    
	    //var dTol = new Date( pEv.value, pHo.value-1, pNap.value  );
	    //alert( dTol );
	    //var dIg = dTol + pPluszNap;
	    //alert(dIg);
	   // pEv2.selectedIndex = dIg.getFullYear();
	    // pHo2.selectedIndex = dIg.getMonth();
	    alert(dIg);
	    alert(dIg.getDate());
	    pNap2.selectedIndex = dIg.getDate();
	}
	*/
}



function hossz( pTa, pMax, pKiir )
{
 var tex = pTa.value;
 var len = tex.length;
 
 if( len > pMax )
 {
     tex = tex.substring( 0, pMax );
     pTa.value = tex;
     len = tex.length;
 }
 pKiir.innerHTML = (pMax-len) +"/" +pMax ;
}


function torles()
{
    return confirm( "Biztos hogy törli?" );
}

function mentes()
{
    return confirm( "Menti a módosításokat?" );
}

function megsem()
{
    if( had_changes )
    {
        if (confirm("Eldobja a módosításokat?")) {
            had_changes = false;
            return true;
        }
        else
            return false;
	}
	else
	    return true;
}


function ch()
{
	//this.style.bgcolor = 'red';
	this.style.color = 'red';
	had_changes = true;
}

function modi_fi( pNode )
{
	if( pNode != null && pNode != undefined )
	{
	    var tagName = pNode.name ? pNode.tagName.toLowerCase() : null;
		if( tagName == "input" || tagName == "textarea" || tagName == "checkbox" || tagName == "select" )
		{
			//alert( pNode.name+" - "+tagName );
			pNode.onchange = ch;
		}
		for( var i=0; i<pNode.childNodes.length; i++ )
		{
				modi_fi( pNode.childNodes[i] );
		}
	}
}



/*** ***/

function inc_date(pDatum, pNap) 
{
    var x = new String(pDatum);

    if (x.indexOf('-', 5) == 6) 
    {
        x=x.replace(/-/, '-0');
    }
  /*  
    alert( x );    
    alert(x.substr(0, 4));
    alert(x.substr(5, 2));
    alert(x.substr(8, 2));
*/
    var xDatum = new Date();
    xDatum.setFullYear(parseInt(x.substr(0, 4)), parseInt(x.substr(5, 2)), parseInt(x.substr(8, 2)));
    xDatum.setTime( xDatum.getTime() + (new Date(pNap * 24 * 60 * 60 * 1000)).getTime() );
    return xDatum.toDateString();    
}


function show(pElement) 
{
    var x = document.getElementById(pElement);
    x.style.display = 'block';
    x.style.visibility = 'visible';    
}