// JavaScript Document

var SimpleGui={version:"0.0.1"};
var MainFormId="MainFormId";

SimpleGui.ShowHideItem = function(id, status){
	if(!status)
	{
		if(id){
			if(document.getElementById(id)){
				(document.getElementById(id).style.display=="none")?(document.getElementById(id).style.display=""):(document.getElementById(id).style.display="none");
			}else{
				alert('Error: no element with such id.'+id);
			}
		}else {
			alert('Error: no element id.');
		}
	} else
	{
		if(status==1)
		{
			if(document.getElementById(id))	(document.getElementById(id).style.display=="");
			alert(status);
		} 
		if(status==0)
		{
			if(document.getElementById(id))	(document.getElementById(id).style.display=="none");
			alert(status);
		}
	}
}

SimpleGui.DelConfirm = function(strLink)
{
	if(window.confirm('Видалити цей запис з бази даних?'))
	{
		location.replace(strLink);
		return true;
	} else{
		return false;
	}
}

SimpleGui.takeJump = function(value,normalUrl)
{
	 if(value){
		 if(normalUrl){
			 document.location.replace(normalUrl+value);
		 } else {
			alert('Error: no Url.');
		 }
	 } else {
		alert('Error: no value.');
	 }
}

SimpleGui.ClearField = function(id)
{
	if(id){
		if(document.getElementById(id)){
			document.getElementById(id).value="";
		}else{
			alert('Error: no element with such id: '+id);
		}
	}else {
		alert('Error: no element id.');
	}	
}

SimpleGui.MessageBox = function(boxType, getValue, getId)
{ 
	if(boxType==0)
	{
		if(typeof getValue == 'string') 
		{
			document.getElementById(MainFormId).innerHTML='<table width="250" border="0" cellpadding="0" cellspacing="0" class="window_form" id="AlertForm"><tr><td height="25" class="window_top_bg"><div style="float:left" class="window_title">Alert</div><div style="float:right"><img src="Addons/SimpleAjaxGui/resources/images/close_16_16.png" alt="Close" width="16" height="16" style="cursor:hand" onclick="javascript:SimpleGui.Close(\'AlertForm\')" /></div></td></tr><tr><td height="40" align="left" valign="top" style=""><div style="float:left; width:40px;" align="center"><img src="Addons/SimpleAjaxGui/resources/images/ok.png" width="32" height="32" /></div><div style="float:left">'+getValue+'</div></td></tr><tr><td height="30" align="center" valign="middle" style=""><input name="ButtonOk" type="button" class="buttonStyle" id="ButtonOk" value="Yes" onclick="javascript:SimpleGui.Confirmed(\'2\')" /></td></tr></table>';
		} 
		else 
		{
			document.getElementById(MainFormId).innerHTML='<table width="250" border="0" cellpadding="0" cellspacing="0" class="window_form" id="AlertForm"><tr><td height="25" class="window_top_bg"><div style="float:left" class="window_title">Alert</div><div style="float:right"><img src="Addons/SimpleAjaxGui/resources/images/close_16_16.png" alt="Close" width="16" height="16" style="cursor:hand" onclick="javascript:SimpleGui.Close(\'AlertForm\')" /></div></td></tr><tr><td height="40" align="left" valign="top" style=""><div style="float:left; width:40px;" align="center"><img src="Addons/SimpleAjaxGui/resources/images/ok.png" width="32" height="32" /></div><div style="float:left">'+noValue+'</div></td></tr><tr><td height="30" align="center" valign="middle" style=""><input name="ButtonOk" type="button" class="buttonStyle" id="ButtonOk" value="Yes" onclick="javascript:SimpleGui.Close(\'AlertForm\')" /></td></tr></table>';		
		}
	} 
	else 
	{
		alert(getValue+' '+boxType)
	}
}
