function getValidForm(formName)
{
	var theform;
	if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1)
	{
		theform = eval("document." + formName);
	}
	else
	{
		theform = document.forms[formName];
	}
	return theform;
}

function clearLoginFiels()
{
	alert('hola');
	getValidForm('AdminAuthentication')('txtEmail').value = '';
	getValidForm('AdminAuthentication')('txtPass').value = '';
}

function ismaxlength(obj)
{
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength-1)
	obj.value=obj.value.substring(0,mlength-1)
}

//Before postBack
function PostDelete(itemName, line2)
{
	var res;
	if(itemName && (itemName != ""))
	{
		res = 'Are you sure you want to delete "' + itemName + '"?';
	}
	else
	{
		res = 'Are you sure you want to delete this item?';
	}
	if(line2 && (line2 != ""))
	{
		res += "\n" + line2;
	}
	return confirm(res);
}

function PopUp(url, width, height, name)
{
	if(!width) width = 550;
	if(!height) height = 450;
	if(!name) name = null;
	var left = (screen.width/2) - (width/2);
	var top = (screen.height/2) - (height/2);
	var win;
	win = window.open(url, name, 'left=' + left + ',top=' + top + ',width=' + width + ',height=' + height + ',toolbar=0,resizable=0');
	win.focus();
	return(win);
}

var popUpWindow;
function PopUpWin(url, id)
{
	var first = true;
	if(url)
	{	
		if(id) url += "?id=" + id;
		
		popUpWindow = PopUp(url, 500, 400, "product");
	}
}

function ClosePopUps()
{
	if(popUpWindow)
	{
		popUpWindow.close();
	}
}

function disableListItems(checkBoxListId, checkBoxIndex, checksTodisableId, numOfItems)
{
	// Get the checkboxlist object.
	objCtrl = document.getElementById(checkBoxListId);
	
	// Does the checkboxlist not exist?
	if(objCtrl == null)
	{
		return;
	}

	var i = 0;
	var objItem = null;
	// Get the checkbox to verify.
	var objItemChecked = 
	document.getElementById(checkBoxListId + '_' + checkBoxIndex);

	// Does the individual checkbox exist?
	if(objItemChecked == null)
	{
		return;
	}

	// Is the checkbox to verify checked?
	var isChecked = objItemChecked.checked;
	
	// Loop through the checkboxes in the list.
	for(i = 0; i < numOfItems; i++)
	{
		objItem = document.getElementById(checksTodisableId + '_' + i);

		if(objItem == null)
		{
			continue;
		}

		// Disable/Enable the checkbox.
		objItem.disabled = isChecked;
		// Should the checkbox be disabled?
		if(isChecked)
		{
			// Uncheck the checkbox.
			objItem.checked = false;
		}
	}
}
