
// JScript source code
function NavMouseOver(uiElement)
{
    uiElement.style.cursor ='hand';
    if (uiElement.className != "ent_main_nav_highlight" && uiElement.className != "ent_main_nav_highlightPerm" )
    {
        uiElement.className = 'ent_main_nav_highlight';
    }
}

function actionswap(formObj)
{
    formObj.action = formObj.selectbox.value;
    formObj.submit();
}

function NavMouseout(uiElement)
{
    if (uiElement.className != "ent_main_nav_highlightPerm")
    {
        uiElement.className = 'ent_main_nav';
    }
}

 
function clicked(url)
{
    location.href = url;
}

function doSearch(formAction)
{
var el=document.getElementById("schkbx2");
    if(el!=null)
    {
       if(el.checked)
        {
            ent_search.action = formAction;  
         }
     }
}
function pop_getEl(o)
{
    return document.getElementById(o);
}        

var videowindow = '';

function OpenVideoWindow(url)
{
    if (!videowindow.closed && videowindow.location)
    {
        videowindow.location.href = url;
    }
    else
    {
        videowindow=window.open(url, "videowindow","resizable=no,toolbar=no,width=780,height=300");
        if (!videowindow.opener) videowindow.opener = self;
    }
    
    if (videowindow.focus) 
    {
        videowindow.focus();
    }
    return false;
}

var images = new Array();
var chooseImageClicked = false;

function loadimage(imageSource, imageWidth, imageHeight, imageAlt, imageCopyright)
{
    var img = new Object();
    img.setAttribute('src', imageSource);
    img.setAttribute('width', imageWidth);
    img.setAttribute('height', imageHeight);
    img.setAttribute('alt', imageAlt);
    img.setAttribute('copyright', imageCopyright);
    return img;
}

function loadimages(srcForm)
{
    
    var loadingmessage = document.getElementById('largeimageloading');
    if (loadingmessage)
    {
        loadingmessage.innerHTML = '';
        loadingmessage.style.display = 'none';
    }
    
    var srcForm = document.pgform;
    //Populate Title
    document.getElementById("boxheadertitle").innerHTML = srcForm.titleprefix.value + "'" + srcForm.pgtitle.value + "'" + srcForm.titlesuffix.value;
      
    //Populate Return URL
    var returnlink = document.getElementById('returnlink');
    returnlink.href = srcForm.pgreturnurl.value;
    returnlink.innerHTML = srcForm.returnlinkprefix.value + "'" + srcForm.pgtitle.value + "'" + srcForm.returnlinksuffix.value;
    
    //Set window title - append Film name
    window.document.title =  srcForm.pgtitle.value + ' - ' + window.document.title;

    if (document.getElementById("breadcrumb").firstChild.firstChild.firstChild.childNodes.length == 3)
    {
        document.getElementById("breadcrumb").firstChild.firstChild.firstChild.childNodes[1].firstChild.innerHTML = srcForm.pgtitle.value;
        document.getElementById("breadcrumb").firstChild.firstChild.firstChild.childNodes[1].firstChild.href = srcForm.pgreturnurl.value;
    }

    //add breadcrumb to footer
    document.write('<div class="pgbreadcrumb">'); 
    document.write(document.getElementById("breadcrumb").innerHTML);
    document.write('</div>');
    //Show image
    displayImage(srcForm);
}

function displayImage(srcForm)
{

      var imagePos = parseInt(srcForm.pgimageindex.value);
      if (isNaN(imagePos))
      { 
        imagePos =1;
      }
    //Populate image array
    var imagearraystring = srcForm.pgimagearray.value;
    var imagearraystrings = imagearraystring.split(";");
    var imagestrings = imagearraystrings[imagePos -1].split("|");
    var imageWidth = parseInt(imagestrings[2]);
    var imageHeight = parseInt(imagestrings[3]);
    
      if (imageWidth > 400)
      {
        imageScaler = 400/imageWidth;
        imageWidth = imageWidth * imageScaler;
        imageHeight = imageHeight * imageScaler;
      }
      var largeimage = document.getElementById("largeimage");
      largeimage.setAttribute('src',imagestrings[1]);
      largeimage.setAttribute('width',imageWidth);
      largeimage.setAttribute('height',imageHeight);
      largeimage.setAttribute('title',imagestrings[4]);
      largeimage.setAttribute('alt',imagestrings[4]);
      
      document.getElementById("largeimageframe").style.width = imageWidth;
      document.getElementById("largeimagecopyright").style.width = imageWidth.toString() + 'px';
      document.getElementById("largeimageframe").style.textAlign = 'center';

      document.getElementById("largeimagetitle").innerHTML = imagestrings[4];
      document.getElementById("largeimagecount").innerHTML = imagePos + '&#160;' + srcForm.of_string.value + '&#160;' + (imagearraystrings.length).toString();
      document.getElementById("largeimagebuttons").style.width = imageWidth + 4;
      document.getElementById("largeimagecopyright").innerHTML = imagestrings[5].length > 0 ? '&copy;&#160;' + imagestrings[5]: '';
      
}

function chooseImage(imageMove,srcForm, reloadPage)
{

    
    var imagearraystring = srcForm.pgimagearray.value;
    var imagearraystrings = imagearraystring.split(";");
    if (!chooseImageClicked)
    {
    
        var imagePos = parseInt(srcForm.pgimageindex.value);
        if (!isNaN(imagePos))
        {
            imagePos += imageMove;
            if (imagePos > imagearraystrings.length)
            {
                imagePos = 1;
            }
            else if (imagePos < 1)
            {
                imagePos = imagearraystrings.length;
            }

            document.forms['pgform'].elements['pgimageindex'].value = imagePos;

            chooseImageClicked = true; //once clicked, wait for submit to happen
            srcForm.submit();
        }
    }
}


function image_onclick(srcElement,imagePos)
{
    document.pgform.PGimageindex.value = imagePos;
    document.pgform.PGreturnurl.value = document.location.href;
}
