﻿// JScript File

//used by the openAdd***Window functions - makes sure the
//openere page is the right one.
//this function is used for folowwing type of scnario:
//in p_main you have an add photo / add biography / add eulogy links
//when they are pressed users sometimes get confused about what they are adding
//as they don't see it (a new photo is not seen on main page), so we move them
//to the right page
function modifyOpenerHref(requiredHref, siteId)
{
    if (window.location.href.indexOf(requiredHref) == -1)
    {   
        
        //added to comply with edit mode
        if (window.location.href.indexOf('state=e') > 0)
            window.location.href = requiredHref + '?state=e&sid=' + siteId;
        //this condition maintains a query string in requiredHref
        else if (requiredHref.indexOf('?') == -1)
            window.location.href = requiredHref + '?sid=' + siteId;
        else
           window.location.href = requiredHref + '&sid=' + siteId; 
    }
}

function openAddTalkbackWindow(siteId)
{
    openModalWindow('500', '500', 'forms/addTalkbackItem.aspx?sid=' + siteId);
}

function openAddPhotoWindow(siteId)
{
    openModalWindow('500', '500', 'forms/addPhoto.aspx?sid=' + siteId);
    modifyOpenerHref('p_pictures.aspx', siteId);   
}

function openAddEulogyWindow(siteId)
{
    openModalWindow('600', '650', 'forms/addEulogy.aspx?sid=' + siteId);
     modifyOpenerHref('p_eulogies.aspx', siteId);   
}

function openAddBiographyItemWindow(siteId)
{
    openModalWindow('600', '650', 'forms/addBiographyItem.aspx?sid=' + siteId);
     modifyOpenerHref('p_biography.aspx', siteId) ;  
}

function openImageItemWindow(tbID)
{
    openResizableWindow('620', '520', 'p_image_open.aspx?tbid=' + tbID);
}

