function oldsetImgSrc()
{
	var imgpath = 'custom.php?motive='+document.getElementById('motive').value+'&font='+document.getElementById('font').value+'&msg='+document.getElementById('msg').value+'&fontsize='+document.getElementById('fontsize').value+'&fontcolor='+document.getElementById('fontcolor').value;
	document.getElementById('customImg').src = imgpath;
}

// new
function setImgSrc()
{
	showsubmit();
	var imgpath = 'inc/inc_customimage.php?maxim='+$('encode_maxim').value+'&motiv='+$('newmotiv').value+'&fontsize='+$('newfontsize').value+'&fgcolor='+$('newfgcolor').value+'&bgcolor='+$('newbgcolor').value+'&fonttype='+$('newfonttype').value+'&shadow='+$('newshadow').value+'&pos_x='+$('newpos_x').value+'&pos_y='+$('newpos_y').value;
	$('customImg').src = imgpath;
}

function es_form()
{
	$('sendform').submit();
}

function es_position(_x, _y)
{
	$('newpos_x').value = eval($('newpos_x').value)+eval(_x);
	$('newpos_y').value = eval($('newpos_y').value)+eval(_y);
	setImgSrc();
	//es_form();
}

function es_fonttype(ttf)
{
	$('newfonttype').value = ttf;
	es_form();
}
function es_fontcolor(color)
{
	$('newfgcolor').value = color;
	es_form();
}
function es_backcolor(color)
{
	$('newbgcolor').value = color;
	$('newshadow').value = '1';
	es_form();
}

function es_fontsize(nextfont)
{
	
	$('newfontsize').value = eval($('newfontsize').value) + eval(nextfont);
	
	if($('newfontsize').value > 48)
	{
		$('newfontsize').value = 48;
	}
	if($('newfontsize').value < 12)
	{
		$('newfontsize').value = 12;
	}
	setImgSrc();
	//es_form();
	
}

function es_motiv(motiv)
{
	$('newmotiv').value = motiv;
	es_form();
}

function es_foreground(value)
{
	if(value)
	{
		$('foreground').style.visibility = 'visible';
		posForeground();
	}
	else
	{
		$('foreground').style.visibility = 'hidden';
	}
}

function debug(obj) 
{ 
     var i = 0; 
     var list; 
      
     for (prop in obj) 
     { 
          list += prop+" => "+obj[prop]+"\n"; 
           
          if (i%20 == 0) 
          { 
               alert(list); 
               list = ""; 
          } 
          i++; 
     } 
}

function showsubmit()
{
	if($('newmaxim').value != "")
	{
		$('maximsubmit').style.visibility = 'visible'
	}
	else
	{
		$('maximsubmit').style.visibility = 'hidden'
	}
}


var db = (document.compatMode && document.compatMode.toLowerCase() != "backcompat") ? document.documentElement : (document.body || null);
function getInt(x,y)
{
	return isNaN(y = parseInt(x)) ? 0 : y;
}

function getWinWidth()
{
	return (db && db.clientWidth) ? db.clientWidth : (window.innerWidth || 0);
}

function getWinHeight()
{
	return getInt((db && db.clientHeight) ? db.clientHeight : (window.innerHeight || 0));
}

function getScrollPosX()
{
	return getInt(window.pageXOffset || (db ? db.scrollLeft : 0));
}

function getScrollPosY()
{
	return getInt(window.pageYOffset || (db ? db.scrollTop : 0));
}

function posForeground()
{
	if($('foreground'))
	{
		if($('foreground').style.visibility == 'visible')
		{
			var y = getInt(getScrollPosY()+(getWinHeight()-300)/2)
			$('foreground').style.top = y+'px';
			var x = getInt(getScrollPosX()+(getWinWidth()-700)/2)
			$('foreground').style.left = x+'px';		
		}
	}
}
