var _showFunctions_currentLanguageMark = null;

function OpenSection(Publication, Features)
{
	if(Features != null)
	{
		window.open(LevelsUpPath() + "Clients/ShowSection.aspx?OriginId=" + Publication ,"popup",  Features,"");
	}
	else
	{
		window.open(LevelsUpPath() + "Clients/ShowSection.aspx?OriginId=" + Publication ,"_self");
	}
}
function OpenSectionPageClear(sectionId, features)
{
	if(features != null)
	{
		window.open(LevelsUpPath() + "Clients/ShowPageClear.aspx?PostId=" + sectionId ,"popup",  features,"");
	}
	else
	{
		window.open(LevelsUpPath() + "Clients/ShowPageClear.aspx?PostId=" + sectionId ,"_self");
	}
}
function OpenPublication(Publication, Features)
{
	if(Features != null)
	{
		window.open(LevelsUpPath() + "File/ViewLinkedFile.aspx?PublicationId=" + Publication ,"popup",  Features,"");
	}
	else
	{
		window.open(LevelsUpPath() + "File/ViewLinkedFile.aspx?PublicationId=" + Publication ,"_self");
	}
}
function OpenFileNew(FileID,  Features)
{
	if (Features != null)
	{
		window.open(LevelsUpPath() + "File/ViewLinkedFile.aspx?FileId=" + FileID , "popup" , Features,"");
	}
	else
	{
		window.open(LevelsUpPath() + "File/ViewLinkedFile.aspx?FileId=" + FileID ,"_self");
	}
}

function OpenWindow(sUrl, Features)
{
	if (Features != null)
	{
		//window.open(sUrl , "popup" , Features,"");
		window.open(sUrl,"_blank");
	}
	else
	{
		window.open(sUrl,"_self");
	}

}

function OpenWindowEx(sUrl, Features)
{
	if (Features != null)
	{
		window.open(sUrl ,"_blank",Features);
	}
	else
	{
		window.open(sUrl,"_self");
	}

}

function OpenNewsPopUp(sectionId, newsId)
{
	window.open(LevelsUpPath() + 'Clients/NewsPopUp.aspx?PostId=' + sectionId + '&subitemid=' + newsId,'PopUp', 'width=420, height=320, scrollbars=yes,resizable=yes');
	return false;
}

function LevelsUpPath()
{
    if(_showFunctions_currentLanguageMark != null)
    {
        return '/' + _showFunctions_currentLanguageMark + '/';
    }
    return '';
}

function BuildLevelsUpPath(path)
{
    var oneLevelUp = '../';
    var parts = path.split('/');
    var levelsUpPath = '';
    
    for(var i = 0;i < parts.length - 2;++i)
    {
        levelsUpPath = levelsUpPath + oneLevelUp;
    }
    
    if(levelsUpPath == '')
    {
        levelsUpPath = './';
    }
    
    return levelsUpPath;
}

function RemoveLanguageMark()
{
    var path = new String(window.location.pathname);    
    
    path = path.replace ('/en', '');
    path = path.replace ('/EN', '');
    path = path.replace ('/En', '');
    path = path.replace ('/eN', '');
    
    if (path.charAt(0) != '/')
    {
        path = '/' + path;
    }
    
    return path;
}
