﻿// javascript page functions script, removed from global.js
var openwindow;

function ftnShowPopup(strUrl, strWidth, strHeight, strCallBack)
{
	var canpop = CanCreatePopUp();
	if (canpop == true)
	{
		if (IE)
		{
			ftnShowModal(strUrl, strWidth, strHeight, strCallBack)
		}
		else
		{
			ftnShowWindow(strUrl, strWidth, strHeight)
		}
	}
}

function ftnShowWindow(strUrl, strWidth, strHeight, strFeatures)
{
	if (strFeatures == null)
	{
		strFeatures='width='+strWidth+',height='+strHeight+',toolbar=No,location=No,status=No,menubar=No,scrollbars=Yes,resizable=No';
	}
	else
	{
		strFeatures = 'width='+strWidth+',height='+strHeight+','+ strFeatures;
	}
	openwindow = window.open(strUrl,'popup',strFeatures);
}

function ftnShowModal(strUrl, strWidth, strHeight, strCallBack)
{
	var strFeatures = 'dialogWidth='+strWidth+'px;dialogHeight='+strHeight+'px;help=off;status=no;scroll=yes';
	var returnVal = window.showModalDialog(strUrl,'popup',strFeatures);
	if (strCallBack != null)
	{
		eval(strCallBack+"();");
	}
	else
	{
		if (returnVal != null)
		{
			eval(returnVal+";");
		}
	}
}

function PageEditRedirect()
{
	var querystring = (document.location.href.indexOf("?") > -1)? document.location.href.slice(document.location.href.indexOf("?")) : "";
	document.location.href = "PageEditRedirectHandler.axd?u=" + document.location.pathname + querystring;
}

function previewAssetDetails(panel, rolloverImage) {
    var $img = $(rolloverImage);
    var $previewBox = $(panel);
    $(panel).css({ 'width': '450px' });

    var pos = $img.offset();
    var posLeft = pos.left + $img.width();
    var posTop = pos.top;

    if (posLeft + ($previewBox.width() + 20) > $(window).width()) {
        posLeft = (pos.left - $previewBox.width())
    };

    if (posTop + ($previewBox.height() + 20) > $(window).height()) {
        posTop = (pos.top - $previewBox.height())
    };

    $(panel).css({ 'width': '450px', 'position': 'absolute', 'top': posTop, 'left': posLeft });
    $(panel).show();
}

