getTarget = function( hEvent )
{
	hElm =  ( hEvent.srcElement ) ? hEvent.srcElement : hEvent.originalTarget
	try
	{
		if( typeof hElm.tagName == 'undefined' ) return  null
		while( ( hElm.tagName ) && !( /body/i.test( hElm.tagName ) ) )
		{
			if( hElm.getAttribute( 'texter' ) != null )
			{
				return hElm
			}
			hElm = hElm.parentNode
		}
	}
	catch( hException )
	{}
	return null
}

_writeText = function( hEvent )
{
    if( hEvent == null ) hEvent = window.event
    hTarget = getTarget( hEvent )
    if( hTarget )
    {	
        writeText( hTarget.getAttribute( 'texter' ) )
		return false
    }
}

function writeText( sData )
{
	var aData = sData.split( '#' )
	for( nI = 0; nI < aData.length; nI++ )
	{
		var aText = aData[ nI ].split( '|' )
		document.getElementById( aText[0] ).text = aText[1]
	}
}

initAutoTexter = function( hEl )
{
   	if( document.attachEvent ) 
   	{
   		document.attachEvent( 'onmouseover', _writeText )
   	}
   	else if( document.addEventListener )
   	{
   		document.addEventListener( 'mouseover', _writeText, false )
   	}
}


var hT
var hB

onload = function()
{
	hT = document.getElementById( 'hintTitle' )
	hB = document.getElementById( 'hintBody' )
	initAutoTexter()
}

function wT( sT, sB )
{
	if( hT && hB )
	{
		hT.text = sT
		hB.text = sB
	}
}

/*email*/
function saveMail()
{
	var hEmail = document.getElementById( 'userMail' )
	var sValue = hEmail.value
	if ( (sValue.indexOf( '@' ) == -1 ) || ( sValue == '' ) || ( sValue == 'mail@domain.com' ) ) 
	{
	    alert( 'Моля въведете email адрес!' )
	}
	else 
	{
		hSubmitFrame = document.getElementById( 'submitFrame' )
		//hSubmitFrame.location.href = 'maillist.php?APP_ACTION=SAVE&EMAIL='+sValue
		hSubmitFrame.src = './maillist.php?APP_ACTION=SAVE&EMAIL='+sValue
		hEmail.blur()
		hEmail.value = 'mail@domain.com'
	}
}

function prepareMail( hEl, bFocus )
{
	var sValue = 'mail@domain.com'
	if( bFocus )
	{
		if( hEl.value != sValue )
		{
			sValue = hEl.value
		}
		else
		{
			sValue = ''
		}
	}
	else
	{
		if( ( hEl.value != sValue ) && ( hEl.value != '' ) )
		{
			sValue = hEl.value
		}
	}
	hEl.value = sValue
}

