function textareakeypress(textareaobject, mlength)
{
	if(window.event) 
	{ 
		if ((window.event.keyCode == 8)||(window.event.keyCode==46))
		{
			return true;  
		} 
		if (textareaobject.getAttribute) 
		{ 
			if (textareaobject.getAttribute("maxlength")) 
			{ 
				mlength = this.getAttribute("maxlength"); 
			}
		}
		if (textareaobject.value.length < mlength)
		{ 
			return true; 
		}else { 
			window.event.returnValue = false; 
			return false; 
		} 
	}else{
		return true;
	}
}

function textareapaste(textareaobject,mlength)
{
	
	if (window.clipboardData) 
	{ 
		var sNewString = window.clipboardData.getData('Text'); 
		if (('' + textareaobject.value + sNewString).length > mlength) 
		{ 
			event.returnValue = false; 
			return false; 
		} 
	} 
	else 
	{  
		return true;  
	}
}

function textareachange(textareaobject,mlength)
{
	if (textareaobject.value.length > mlength) 
	{ 
		textareaobject.value = textareaobject.value.substr(0,mlength); 
		return true; 
	} 
}

function handleEnter (field, event) {
	try{
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			
			return false;
		} 
		else
		{
			return true;
		}
	}catch(e){
		return true;
	}
}

function getObjectById(id){
	var o;
	if (window.document.all)
	{
		o= window.document.all("" + id);
	}else{
		if (window.document.getElementById){
			o = window.document.getElementById("" + id);
		}
	}
	return o;
}


function goClientSearch(objectidFromText)
{
	var oObject;
	var sValue;
	oObject = getObjectById(objectidFromText);
	sValue = oObject.value;
	
	if (sValue != "")
	{
		window.document.location = _urlPartMountInfo + "/Pages/ShowSearch.aspx?SearchText=" + encodeURI(sValue);
	}
}

function abrirpagina(show,sId,sectiontypeid,navigateToUrl,MenuInEditMode,canOnlyNavigate)
{
    if(navigateToUrl == null)
    {
        navigateToUrl = '';
    }
    
	var iCanOnlyNavigate = 0;
	if (canOnlyNavigate == "undefined"){
		iCanOnlyNavigate = 0;
	}else{
		if (canOnlyNavigate == 1){
			iCanOnlyNavigate = 1;
		}else{
			iCanOnlyNavigate = 0;
		}
	}
	if (!MenuInEditMode)
	{
		if (sectiontypeid != 7)
		{
			if (sectiontypeid != 6){
				if (show == 2)
				{
				    if(navigateToUrl == '')
				    {
					    window.document.location = _urlPartMountInfo + "/Pages/GoLink.aspx?OriginId=" + sId;
					}
					else
					{					    
					    window.document.location = _urlPartMountInfo + navigateToUrl;
					}
					
				}else{
					//
					
				}
			}
			else
			{
			    if(navigateToUrl == '')
			    {
				    window.document.location = _urlPartMountInfo + "/Pages/GoLink.aspx?OriginId=" + sId;
				}
				else
				{
				    window.document.location = _urlPartMountInfo + navigateToUrl;
				}
			}
		}
	}
	else
	{
		EditMenuSection(sId,sectiontypeid,show,iCanOnlyNavigate);
	}
}


function abrirpaginaformenu(show,sId,sectiontypeid,navigateToUrl,MenuInEditMode,ActualSiteId,canOnlyNavigate)
{
    if(navigateToUrl == null)
    {
        navigateToUrl = '';
    }
        
	var iCanOnlyNavigate = 0;
	if (canOnlyNavigate == "undefined"){
		iCanOnlyNavigate = 0;
	}else{
		if (canOnlyNavigate == 1){
			iCanOnlyNavigate = 1;
		}else{
			iCanOnlyNavigate = 0;
		}
	}
	if (!MenuInEditMode)
	{
		if (sectiontypeid != 7)
		{
			if (sectiontypeid != 6)
			{
				if (show == 2)
				{
				    if(navigateToUrl == '')
				    {
					    window.document.location = _urlPartMountInfo + "/Pages/GoLink.aspx?OriginId=" + sId;
					}
					else
					{					    
					    window.document.location = _urlPartMountInfo + navigateToUrl;
					}
				}
			}
			else
			{	
		        if(navigateToUrl == '')
			    {
				    window.document.location = _urlPartMountInfo + "/Pages/GoLink.aspx?OriginId=" + sId;
				}
				else
				{
				    window.document.location = _urlPartMountInfo + navigateToUrl;
				}
			}
		}
	}
	else
	{
		EditMenuSection(sId,sectiontypeid,show,ActualSiteId,iCanOnlyNavigate);
	}
}


function OpenSection(Publication, Features)
{
	var sOpen = "_self";
	if(Features != null)
	{
		window.open(_urlPartMountInfo + "/clients/ShowSection.aspx?OriginId=" + Publication ,"popup",  Features,"");
		//window.open(_urlPartMountInfo + "/clients/ShowSection.aspx?OriginId=" + Publication ,"_blank");
	}
	else
	{
		if (window["ForceOpenInNewWindow"]){
			sOpen = "PopUpSection";
		}	
		window.open(_urlPartMountInfo + "/clients/ShowSection.aspx?OriginId=" + Publication ,sOpen);
	}
}
function OpenPublication(Publication, Features)
{
	var sOpen = "_self";
	if(Features != null)
	{
		window.open(_urlPartMountInfo + "/File/ViewLinkedFile.aspx?PublicationId=" + Publication ,"popup",  Features,"");
	}
	else
	{
		if (window["ForceOpenInNewWindow"]){
			sOpen = "PopUpSection";
		}
		window.open(_urlPartMountInfo + "/File/ViewLinkedFile.aspx?PublicationId=" + Publication ,sOpen);
	}
}
function OpenFileNew(FileID,  Features)
{
	var sOpen = "_self";
	if (Features != null)
	{
		window.open(_urlPartMountInfo + "/File/ViewLinkedFile.aspx?FileId=" + FileID , "popup" , Features,"");
	}
	else
	{
		if (window["ForceOpenInNewWindow"]){
			sOpen = "PopUpSection";
		}
		window.open(_urlPartMountInfo + "/File/ViewLinkedFile.aspx?FileId=" + FileID ,sOpen);
	}
}

function OpenWindow(sUrl, Features)
{
	var sOpen = "_self";
	if (Features != null)
	{
		//window.open(sUrl , "popup" , Features,"");
		window.open(sUrl,"_blank");
	}
	else
	{
		if (window["ForceOpenInNewWindow"]){
			sOpen = "PopUpSection";
		}
		window.open(sUrl,sOpen);
	}

}

function ShowConfirmEditSectionPage()
{
	var bReturn = false;
	var objDialogWindow;
	var oWindow;
	var theURL = _urlPartMountInfo + "/Clients/ShowConfirmEditPage.aspx";
	var features = "DialogWidth:400px;DialogHeight:300px;center:1;resizable:0;scroll:off;";
	oWindow = window;
	var bReturnValue;
	bReturnValue = window.showModalDialog(theURL,oWindow,features);
	if (bReturnValue){
		return bReturnValue;
	}else{
		return bReturn;
	}
}