function winPop(pageToLoad,winName,width,height,center,scroll)
{
    xposition=0; yposition=0;
    if((parseInt(navigator.appVersion) >= 4 ) && (center))
    {
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }
    args = "width=" + width + ","
    + "height=" + height + ","
    + "location=0,"
    + "menubar=0,"
    + "resizable=0,"
    + "scrollbars="+scroll+", "
    + "status=1,"
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only

    return window.open(pageToLoad,winName,args);
}

function printPS()
{
	winPop('/print.aspx','',450,500,1,1)
}

function imageOpen(pFolder,pImage,pHeight)
{
	winPop('/journalist/upload_view.aspx?' + pFolder + '/' + pImage,'',pFolder,pHeight,1,0)
}

function imagePop(pContentVersionID)
{
	winPop('image.aspx?cvid=' + pContentVersionID,'',567,500,1,1);
}

function formatBox(src,pText)
{
	if(src.value == pText)
	{
		src.value 				= '';
	}

	src.className 				= '';
}

function formatBoxReset(src,pText)
{
	if(src.value == '')
	{
		src.value 				= pText;
		src.className 			= 'inputOff';
	}
}

function submitForm(src)
{
    var bValid 					= true;
    var ii;
    var theinput;

    for(ii = 0;ii < src.elements.length;ii++)
    {
        theinput 				= src.elements[ii];

        if((theinput.type == 'text') || (theinput.type == 'select-one'))
        {
            if(theinput.id == 'REQUIRED')
            {
                if((theinput.value == '') || ((theinput.value.substring(0,1) == '[') && (theinput.value.substring(0,1) == '[')))
                {
                    bValid		= false;
                }
            }
        }
    }

    if(bValid)
    {
        src.submit();
    }
    else
    {
        alert('Please complete the mandatory fields.');
    }
}

//////////////////////////////////////////////////////////////

var iTop			= 0;
var iLeft			= 0;

function findPos(obj)
{
	if(obj.offsetParent)
	{
		iTop		= obj.offsetTop;
		iLeft		= obj.offsetLeft;

		while(obj = obj.offsetParent)
		{
			iTop	+= obj.offsetTop;
			iLeft	+= obj.offsetLeft;
		}
	}
}

function moveDiv(pDivRef,pDivMove)
{
	try
	{
		findPos(document.getElementById(pDivRef));

		var iWidth	= parseInt((document.getElementById(pDivRef).style.width).replace('px',''));

		if(isNaN(iWidth))
		{
			iWidth	= 15;
//			iTop	= iTop - 8;
		}

		document.getElementById(pDivMove).style.top = (iTop - 200) + 'px';
		document.getElementById(pDivMove).style.left = (iLeft - 230) + 'px';

		showDiv(pDivMove);
	}
	catch(app)
	{
	}
}

function showDiv(pDiv)
{
	document.getElementById(pDiv).style.display = 'block';
}
function hide()
{
	document.getElementById('shopPop').style.display = 'none';
}
function show()
{
	document.getElementById('shopPop').style.display = 'block';
}
