// Name: Popup
// Description: manages popups for site
// Author: John Hayes
// Created: 06/08/03
// Modifications:{date, modifier}: description
// Usage: editorials CET


function open_win (path)
{
open_custom(path,500,400);
}

function open_image_win (path)
{
open_custom(path,600,600);
}

function open_wysiwyg_win ( path )
{
open_custom(path,663,520);
}

function open_link_win (path)
{
open_custom(path,317,165);
}

function open_text_win ( path )
{
open_custom(path,400,800);
}

function open_preview(path,store,item)
{
open_custom_with_location(path + '/store' + store + '/item' + item,800,800,40,40);
}

function open_preview_promo(path,store,item)
{
open_custom_with_location(path + '/store' + store + '/item' + item,1000,300,0,40);
}

function open_image(store,item)
{
open_custom_with_location('/site/image/store' + store + '/item' + item,980,480,20,20);
}

function open_custom( path,width,height)
{
window.open(path, 'aWindow',' width=' + width + ', height=' + height + ', menubar=no, location=no, resizable=yes, hotkeys=no, directories=no, scrollbars=yes, toolbar=no, titlebar=no, status=no');
}

function open_custom_with_location( path,width,height,left,right)
{
window.open(path, 'aWindow',' width=' + width + ', height=' + height + ', left=' + left + ', right=' + right + ',menubar=no, location=no, resizable=yes, hotkeys=no, directories=no, scrollbars=yes, toolbar=no, titlebar=no, status=no');
}

function open_win_update_field(destination_field,source_field)
{
document.getElementById(destination_field).value = window.opener.document.getElementById(source_field).innerHTML;
}

function close_win_update_field(source_field,destination_field)
{
window.opener.document.getElementById(destination_field).innerHTML = document.getElementById(source_field).value;
self.close();
}

function set_edited_field()
{
document.getElementById('edited').innerHTML = '1';
}


function go_to_page(path,timeout)
{
setTimeout('location = "' + path + '"',timeout);
}

function close_win()
{
setTimeout("closeAndReload()",2000);
}

function closeAndReload()
{
window.opener.location = getURLWithoutQueryString();
self.close();
}

function getURLWithoutQueryString()
{
var url = window.opener.location.href;
var qparts = url.split("?");

if (qparts.length == 0)
{
return url;
}
else
{
return qparts[0];
}
}
