function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function setMainImage(arrid)
{
    var imObj = document.getElementById("div-work-main");
    var textObj = document.getElementById("div-work-text");
    var arrayObj = document.getElementById("full_array");
    var splitCells, splitRows, countpage, count;
    splitRows = arrayObj.value.split("}");
    countpage = splitRows.length - 1;
    
    //Page_Id = 0 | Page_Info_Title = 1 | tyImage_Library_Summary = 2 | 
    //tyImage_Library_Summary_2 = 3 | tyImage_Library_Image_Id = 4 | tyImage_Thumbnail_Id = 5
    //Main_Type = 6 | Thumb_Type = 7 | Media_URL = 8

    if (arrid >= 0)
    {
        var pID, pTitle, summ1, summ2, img1, img2, type1, type2;
        var text_1 = '';
        var imgdata = '';
        
        splitCells = splitRows[arrid].split("{");
        pID = splitCells[0];
        pTitle = splitCells[1];
        summ1 = splitCells[2];
        summ2 = splitCells[3];
        img1 = splitCells[4];
        img2 = splitCells[5];
        type1 = splitCells[6];
        type2 = splitCells[7];
        Media_URL = splitCells[8];
        Thumb_URL = splitCells[9];
        
        switch(type1)
        {
            case "flv":
                
                imgdata = buildPlayer(1, Media_URL, img2, Thumb_URL);
                text_1 = text_1 + '<p>' + summ1 + '</p>';
                text_1 = text_1 + '<p>' + summ2 + '</p>';
                textObj.innerHTML = text_1;
                //document.location = document.getElementById("redURL").value + '&arrid=' + arrid.toString();
                
                break;
            default:
                
                if (img1 > 0)
                {
                    imgdata = imgdata + '<div style=text-align:center;><img src=/embeddedFile.asp?id=' + img1 + '&amp;iheight=280&amp;iwidth=486 title='+ pTitle + ' alt='+ pTitle + ' />';
					imgdata = imgdata + '<p><a href=# onclick=showLargeImage('+ img1 +');>View larger image</a></p></div>';
                }
                
                text_1 = text_1 + '<p>' + summ1 + '</p>';
                text_1 = text_1 + '<p>' + summ2 + '</p>';
                imObj.innerHTML = imgdata;
                textObj.innerHTML = text_1;
                
                break;
        }
  
    }
}

function buildPlayer(typeid, url, thum, Thumb_URL)
{   
    var data = '';
    
    switch(typeid)
    {
        case 1: //Video

            document.getElementById("div-work-main").innerHTML = '<div id=flashcontent></div>';
            var imgholder = document.getElementById("flashcontent");
            var so = new SWFObject('../Artists/flash/phf_player.swf', 'PHF', '487', '281', '8', '#000000');
            so.addVariable('flv', url);
            so.addVariable('img', 'http://www.phf.org.uk/'+Thumb_URL+'');
            so.addParam('allowFullScreen','true');
            so.write(imgholder);
            
            break;
        case 2: //Audio
            
            break;
        default:
            break;
    }
    
    return data;
}

function showLargeImage(valIn)
{
    document.location = document.getElementById("redURL").value + '&large=true&specid=' + valIn.toString();
}
