function submitFormByEnter( obj )
{ 
	if ( document.getElementById("SearchLetter_yp") )
		document.getElementById("SearchLetter_yp").value='';
	
	if ( document.getElementById("SearchLetter_lnk") )
		document.getElementById("SearchLetter_lnk").value='';
	
	if ( document.getElementById("SearchLetter_ent") )
		document.getElementById("SearchLetter_ent").value='';
			
			
	if(event.keyCode == '13'){
                obj.submit();
                }
} 
function submitForm2ByEnter()
{ 
	if(event.keyCode == '13'){
                submitForm2();
                }
} 

/*******************************************/
	FixImagesDone = false;
	FixImages1Done = false;
	function FixLobbyImages_Dyn( w, h, x)
	{
		if( !FixImagesDone )
		{
			FixImagesDone = true;
			colImages0 = document.getElementsByName( x );
			var theImage;
			var theImages = [];
			for( var i = 0; i < colImages0.length; i++ )
			{
				theImages[i] = new Image();
				theImages[i].index = i;
				theImages[i].w = w;
				theImages[i].h = h;
				colImages0[i].style.visibility = "";
				theImages[i].onload = function()
				{
					this.onload = null;
					Resize_Dyn1(colImages0[this.index],this,this.w,this.h);
					//colImages0[this.index].style.visibility = "";
				}
				theImages[i].onerror = function()
				{
					this.onload = null;
					this.onerror = null;
					colImages0[this.index].style.display = "none";
				}
				theImages[i].src = colImages0[i].src;
			}
		}
	}


	function Resize_Dyn1(container,theImage,c_width,c_height)
	{
		try
		{
			var container_width = Number(c_width);
			var container_height = Number(c_height);
			var height = theImage.height;
			var width = theImage.width;
			if( height > container_height || width > container_width )
			{
				var ratio1 = container_height/height;
				var ratio2 = container_width/width;
				var ratio = Math.min(ratio1,ratio2);
				container.width = width*ratio;
				container.height = height*ratio;
			}
			else
			{
				container.width = width;
				container.height = height;
			}
		}
		catch(e){}
	}
/*****************************************/	
function resetFrm( obj )
{
	var fElm=obj.elements;
	for(i=0;i<fElm.length;i++)
	{
	if(fElm[i].type=="text")
		fElm[i].value = "";
	if(fElm[i].type=="hidden")
		fElm[i].value = "";
	if(fElm[i].type=="file")
		fElm[i].value = "";
	if(fElm[i].type=="textarea")
		fElm[i].value = "";
	if(fElm[i].type=="select-one")
		fElm[i].value=-1;
	}
		
}	

function hideShow(x)
{
	//var u=document.getElementById(x).style.display;
	//tablex=x.id
	//alert(x)
	if (document.getElementById(x).style.display == '')
	{
		document.getElementById(x).style.display = 'none';
	}else{
		document.getElementById(x).style.display = '';
	}
}
function openWindow(url,w,h,s) {
	if(!s) {
	s = 'yes';
	}
 var wizWin = window.open(url, null, 'width='+w+',height='+h+',status=no,menubar=no,titlebar=no,scrollbars='+s+',resizable=no')
}
function openWindowGallery(url,w,h) 
{
	s = 'yes';
	var wizWin = window.open(url, null, 'width='+w+',height='+h+',status=no,menubar=no,titlebar=no,scrollbars='+s+',resizable=yes')
}

var ObjDisplayed = new Object(); 
ObjDisplayed.id=""; 

function disp(id) { 
   if (ObjDisplayed.id!="") {
     ObjDisplayed.style.display="none";
     } 
   
   var Obj = eval("document.all.tr"+id); 
   if (Obj!=ObjDisplayed) { 
      ObjDisplayed=Obj; 
      Obj.style.display="inline"; 
    } else { 
      ObjDisplayed= new Object(); 
	  ObjDisplayed.id=""; 
	}
}

function DoFormSubmit( sourceForm, action, target, params, sourceDescription, index ) 
{
	var sourceElement; 
	if( index == null )
		index = "";
	var tmpForm = "<Form id='tmpForm' method='post' action='" + action + "' target='" + target + "'>"; 
	for( var i = 0; i < params.length; i++ ) 
	{ 
		try
		{ 
			sourceElement = document.getElementById(params[i] + index); 
			if(sourceElement.type == "checkbox")
			{
				if ( sourceElement.checked )
					tmpForm += "<Input type='hidden' value='on' name='" + params[i] + "' />";
				else
					tmpForm += "<Input type='hidden' value='off' name='" + params[i] + "' />";
			}
			else
			{
				// It works now only for text fields. If you need more, add checking of tagname here 
				tmpForm += "<Input type='hidden' value='" + sourceElement.value + "' name='" + params[i] + "' />";
			}
		} 
		catch( Ex ) {} 
	} 
	if( sourceDescription != undefined && sourceDescription != null )
		tmpForm += "<Input type='hidden' value='" + sourceDescription + "' name='sourceDescription' />"
	tmpForm += "</Form>"; 
	document.body.insertAdjacentHTML('beforeEnd', tmpForm); 
	document.forms[document.forms.length-1].submit(); 
}
if(typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement)
{
	HTMLElement.prototype.insertAdjacentElement = function(where,parsedNode)
	{
		switch (where)
		{
		case 'beforeBegin':
			this.parentNode.insertBefore(parsedNode,this)
			break;
		case 'afterBegin':
			this.insertBefore(parsedNode,this.firstChild);
			break;
		case 'beforeEnd':
			this.appendChild(parsedNode);
			break;
		case 'afterEnd':
			if (this.nextSibling) 
				this.parentNode.insertBefore(parsedNode,this.nextSibling);
			else 
				this.parentNode.appendChild(parsedNode);
			break;
		}
	}

	HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr)
	{
		var r = this.ownerDocument.createRange();
		r.setStartBefore(this);
		var parsedHTML = r.createContextualFragment(htmlStr);
		this.insertAdjacentElement(where,parsedHTML)
	}


	HTMLElement.prototype.insertAdjacentText = function(where,txtStr)
	{
		var parsedText = document.createTextNode(txtStr)
		this.insertAdjacentElement(where,parsedText)
	}
}
