var SELECTED_COLOR = "#F0D0D0";
var UNSELECTED_COLOR = "#D0D0D0";

var pthdictImages = new Array();
var curImage = -1;
var totalImage = 8;
var slideshowInterval = 6000;
var timerHandle;

var pthdictImages_sp = new Array();
var curImage_sp = -1;
var totalImage_sp = 8;
var slideshowInterval_sp = 6500;
var timerHandle_sp;

function TransformPicture()
{
    curImage = ++curImage % totalImage;
	
    var filterFunction="blendTrans(duration=0.5)";

    var canFilter = false;
    if (document.images.img_pthdict_ppc && document.images.img_pthdict_ppc.style && document.images.img_pthdict_ppc.style.filters)
    {
        target = document.images.img_pthdict_ppc;
        canFilter = true;
    }
    
    if (document.getElementById("img_pthdict_ppc"))
    {
        target = document.getElementById("img_pthdict_ppc");
        canFilter = true;
    }
			
    if (canFilter)
    {
        target.style.filter = filterFunction;
        
	    if (target.filters && target.filters[0])
        {
            target.filters[0].Apply();
            target.filters[0].Play();
        }
    } 
    
    target.src = pthdictImages[curImage].src;
    
    SetTdCss(curImage);
    timerHandle = setTimeout('TransformPicture()', slideshowInterval);
}

function TransformPicture_sp()
{
    curImage_sp = ++curImage_sp % totalImage_sp;
	
    var filterFunction="blendTrans(duration=0.5)";

    var canFilter = false;
    if (document.images.img_pthdict_sp && document.images.img_pthdict_sp.style && document.images.img_pthdict_sp.style.filters)
    {
        target = document.images.img_pthdict_sp;
        canFilter = true;
    }
    
    if (document.getElementById("img_pthdict_sp"))
    {
        target = document.getElementById("img_pthdict_sp");
        canFilter = true;
    }
			
    if (canFilter)
    {
        target.style.filter = filterFunction;
        
	    if (target.filters && target.filters[0])
        {
            target.filters[0].Apply();
            target.filters[0].Play();
        }
    } 
    
    target.src = pthdictImages_sp[curImage_sp].src;
    
    SetTdCss_sp(curImage_sp);
    timerHandle_sp = setTimeout('TransformPicture_sp()', slideshowInterval_sp);
}

function SetTdCss(imageNo)
{
    var curTD;
    for(var i = 0; i < totalImage; ++i)
    {
        curTD = document.getElementById("td_pthdict_ppc"+(i+1));
        if (curTD)
        {
            curTD.style.backgroundColor = (i == imageNo ? SELECTED_COLOR : UNSELECTED_COLOR );
        }
    }
}

function SetTdCss_sp(imageNo)
{
    var curTD;
    for(var i = 0; i < totalImage; ++i)
    {
        curTD = document.getElementById("td_pthdict_sp"+(i+1));
        if (curTD)
        {
            curTD.style.backgroundColor = (i == imageNo ? SELECTED_COLOR : UNSELECTED_COLOR);
        }
    }
}

function SetScreenShot(imageNo)
{
    clearTimeout(timerHandle);
    curImage = imageNo - 1;
    TransformPicture();
}

function SetScreenShot_sp(imageNo)
{
    clearTimeout(timerHandle_sp);
    curImage_sp = imageNo - 1;
    TransformPicture_sp();
}


function LoadScreenShot()
{
    for (var i = 0; i < totalImage; ++i)
    {
        pthdictImages[i] = new Image();
        pthdictImages[i].src = "images/thumbnail/pthdict_ppc" + (i+1) + ".jpg";
    }

    for (var j = 0; j < totalImage_sp; ++j)
    {
        pthdictImages_sp[j] = new Image();
        pthdictImages_sp[j].src = "images/thumbnail/pthdict_sp" + (j+1) + ".jpg";
    }
    
    TransformPicture();
    TransformPicture_sp();
}

function ShowFullSizePicture(picNo)
{
	var newWindow = window.open(pthdictImages[picNo].src.replace('thumbnail/', ''), "PTHDict_PPC_Screen", "width=260,height=350");
	newWindow.focus();
}

function ShowFullSizePicture_sp(picNo)
{
	var newWindow = window.open(pthdictImages_sp[picNo].src.replace('thumbnail/', ''), "PTHDict_SP_Screen", "width=196,height=250");
	newWindow.focus();
}