function New()
{
	var oCollection = document.getElementsByTagName("INPUT");
	if(oCollection != null){
		for(index = 0 ; index < oCollection.length;index ++){
			var oInput = oCollection[index] ;
			if(!oInput.getAttribute("readOnly"))
			{
			    if(oInput.type == "text"){
				     oInput.value = "" ; }
			    if(oInput.type == "password"){
			          oInput.value = "" ;    }		
			    if(oInput.type == "checkbox"){
				oInput.checked = false;}
			}		
		}
	}

	oCollection = document.getElementsByTagName("SELECT");
	if(oCollection != null){
			for(index = 0 ; index < oCollection.length;index ++)
		{
		     
			if(oCollection[index].options.length > 0 && oCollection[index].id!="cb_SearchType")
			{
			 
			   
			     var oOption = oCollection[index].options[0];
			
				oOption.selected = true;  
		
			}
		}
	}

	oCollection = document.getElementsByTagName("TEXTAREA");
	if(oCollection != null){
		for(index = 0 ; index < oCollection.length;index ++){
			oCollection[index].value = "" ;
		}
	}
	
	EnableFirstControl();
}
//----------------------------------------------------------------------------------------------------------------------
function EnableFirstControl()
{
	var oCollection = document.all.tags("INPUT");
	if(oCollection != null){
		for(index = 0 ; index < oCollection.length;index ++){
			var oInput = oCollection[index] ;
			if(oInput.type == "text")
			{
				var Attr = oInput.getAttribute("fec");
				if(Attr == "")
				{
					var ControlName = oInput.id;
					if(!document.all(ControlName).style.display)
						document.all(ControlName).focus();
				}
			}
			if(oInput.type == "checkbox")
			{
				var Attr = oInput.getAttribute("fec");
				if(Attr == "")
				{
					var ControlName = oInput.id;
					if(!document.all(ControlName).style.display)
						document.all(ControlName).focus();
				}
			}
			if(oInput.type == "radio")
			{
				var Attr = oInput.getAttribute("fec");
				if(Attr == "")
				{
					var ControlName = oInput.id;
					if(!document.all(ControlName)[0].disabled)
						if(!document.all(ControlName)[0].style.display)
								document.all(ControlName)[0].focus();
				}
			}
			else // for oInput.type == Password
				{
					var Attr = oInput.getAttribute("fec");
					if(Attr == "")
					{
						var ControlName = oInput.id;
						if(!document.all(ControlName).disabled)
							if(!document.all(ControlName).style.display)
								document.all(ControlName).focus();
					}
				}
		}
	}

	oCollection = document.all.tags("SELECT");
	if(oCollection != null){
		for(index = 0 ; index < oCollection.length;index ++){
			if(oCollection[index].options.length > 0){
				var oSelect = oCollection[index];
				var Attr = oSelect.getAttribute("fec");
				if(Attr == "")
				{
					var ControlName = oSelect.id;
					if(!document.all(ControlName).disabled)
						if(!document.all(ControlName).style.display)
							document.all(ControlName).focus();
				}
			}
		}
	}

	oCollection = document.all.tags("TEXTAREA");
	if(oCollection != null){
		for(index = 0 ; index < oCollection.length;index ++){
				var oInput = oCollection[index] ;
				var Attr = oInput.getAttribute("fec");
				if(Attr == "")
				{
					var ControlName = oCollection[index].id;
					if(!document.all(ControlName).disabled)
						if(!document.all(ControlName).style.display)
							document.all(ControlName).focus();
				}
		}
	}
}		
//----------------------------------------------------------------------------------------------------------------------
// New functions for printing
//----------------------------------------------------------------------------------------------------------------------
function PrintPage(fileName)
{
	//window.open("../"+fileName,null,'height=522,width=642,resizable=no,toolbar=no,scrollbars =yes');
	window.open(fileName,null,'height=522,width=770,left=15,top=15,resizable=yes,toolbar=no,scrollbars =yes');
}
//----------------------------------------------------------------------------------------------------------------------
function RetrieveKey()
{
	var Key = event.keyCode;
	if(Key == "13") //Enter
	{
		//var formName = document.forms(0).name;
		//document.getElementById(formName).onsubmit();
	}
	else if (Key == "27") //Esc
	{
		window.history.back();
	}
}
//------------------------------------------------------------------------------------------------------------------------
function MainPageKey(id)
{
	/*var Key = event.keyCode;
	if(Key == "13") //Enter
	{
		if(id != "")
			document.all(id).focus();		
		else
		{
			var formName = document.forms(0).name;
			document.getElementById(formName).onsubmit();
		}	
	}*/
}
//------------------------------------------------------------------------------------------------------------------------
function ViewData()
{
	window.focus();
	document.getElementById("Data").innerHTML = window.opener.document.getElementById("PrintableData").innerHTML;
	
	if(document.getElementById("NonPrintableData"))
	{
		if(document.getElementById("NonPrintableData").length > 1)
		{
			for(i=0 ; i < document.getElementById("NonPrintableData").length ; i++)
			{
				document.getElementById("NonPrintableData")[i].style.display = "none";
			}	
		}
		else
		{
			document.getElementById("NonPrintableData").style.display = "none";
		}	
	}

	var oCollection = document.getElementsByTagName("INPUT");
	if(oCollection != null){
		for(index = 0 ; index < oCollection.length;index ++){
			var oInput = oCollection[index] ;
			oInput.style.border = "0px";
			oInput.readOnly = "true";
			oInput.style.background = "white";
		}
	}
	
	var oTextAreaCollection = document.getElementsByTagName("TextArea");
	if(oTextAreaCollection != null){
		for(i = 0 ; i < oTextAreaCollection.length;i++){
			var oTextAreaInput = oTextAreaCollection[i] ;
			oTextAreaInput.style.border = "0px";
			oTextAreaInput.readOnly = "true";
			oTextAreaInput.style.background = "white";
			oTextAreaInput.style.overflow = "hidden";
		}
	}
	
	if(document.all.ViewMode)
	{
		var ViewItemsLen = document.all("ViewMode").length;
		if(ViewItemsLen > 1)
		{
			for(i=0 ; i < ViewItemsLen ; i++)
			{
				document.all.ViewMode[i].style.display = "none";
			}
		}
		else
		{
			document.all.ViewMode.style.display = "none";
		}	
	}
	window.print();
}
//------------------------------------------------------------------------------------------------------------------------
function AcceptFRM(formName,formAction)
{
	document.getElementById(formName).action = formAction;
	document.getElementById(formName).method = "post";
	document.getElementById(formName).submit();	
}
//------------------------------------------------------------------------------------------------------------------------
function RejectFRM(formName,formAction)
{
	document.getElementById(formName).action = formAction;
	document.getElementById(formName).method = "post";
	document.getElementById(formName).submit();	
}
//------------------------------------------------------------------------------------------------------------------------
//Must be solve
function Show(id)
{
	var Len = document.all(id).length;
	if (Len > 1)
	{
		for(g=0 ; g < Len ; g++)
		{
			document.all.GoUp(g).style.display = "";
		}
	}	
	else
	{
		document.all.GoUp.style.display = "";
	}
}
//------------------------------------------------------------------------------------------------------------------------
function ShowDownArrow(id)
{
	var Len = document.all(id).length;
	var Num = document.all.PenaltiesNum.value;
	
	if (Len > 1)
	{
		for(g=0 ; g < Len ; g++)
		{
			if(Num > 7) 
				document.all.GoDown(g).style.display = "";
		}
	}	
	else
	{
		if(Num > 7) 
			document.all.GoDown.style.display = "";
	}
}
//------------------------------------------------------------------------------------------------------------------------
function RedirectToPage(url)
{
	fileName = url;
	setInterval("LoadPage(fileName)", 5000);
}
//------------------------------------------------------------------------------------------------------------------------
function LoadPage(url)
{
	window.location.href = url;
}
//----------------------------------------------------------------------------------------------------------------------
function getStatus()
{
	if(document.all.PaymentMethod)
	{
		if(document.all.PaymentMethod(1).checked == true)
		{
			if(document.all.AddHomeDelivery)
			{
				document.all.AddHomeDelivery.disabled = false;
				document.all.AddHomeDelivery.checked = true;
			}	
		}
		else
		{
			if(document.all.AddHomeDelivery)
			{
				document.all.AddHomeDelivery.disabled = true;
				document.all.AddHomeDelivery.checked = false;
			}	
		}
	}	
}
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
function OpenFile(fileName)
{
	window.open(fileName);
}
//----------------------------------------------------------------------------------------------------------------------
function AdjustPrinting()
{
	var Len = document.getElementsByTagName("P").length;
	var Num = parseInt(Len/7);
	var Value = 7;
	for(i=0 ; i < Num-1 ; i++)
	{
		//Check items how many blocks
		document.getElementsByTagName("P")[Value-1].innerHTML = "<BR>";
		Value = parseInt(Value + 7);
	}
}
