﻿var Browser = {
    Version: function() {
        var version = 999; // we assume a sane browser
        if (navigator.appVersion.indexOf("MSIE") != -1)
        // bah, IE again, lets downgrade version number
            version = parseFloat(navigator.appVersion.split("MSIE")[1]);
        return version;
    }
}

function ObjOnMouseOver(th)
{
    var t = getTop(th);
    var l = getLeft(th) 
    var w = th.style.width;

    if(document.all)
    {
        switch (Browser.Version()) 
        {
            case 6:
                t += 10;
                l += 10;
                break;
            case 7:
                t += 9;
                l += 9;
                break;
                
        }
    }
    else
    {
        //ff
    }
    
    th.style.position = "absolute";   
    th.style.left = l + "px";
    th.style.top = t + "px";
    th.style.width = "210px";
    th.className = "photoinfo";
}

function ObjOnMouseOut(th)
{
    th.style.position = "";  
    th.className = "";
}
        
function getTop(e)
{
    var offset=e.offsetTop;
	
    if(e.offsetParent!=null) offset+=getTop(e.offsetParent);
	
    return offset;
}
 
function getLeft(e) 
{
 
    var offset=e.offsetLeft;
	 
    if(e.offsetParent!=null) offset+=getLeft(e.offsetParent);
	 
    return offset;     
}

function MainMenuMouseOver(th, name) 
{
    var obj = document.getElementById(name);
    
    if(obj)
    {
        obj.style.display = "";
    }
    
    var t = getTop(th);
    var l = getLeft(th) + th.offsetWidth;
    
    if(document.all)
    {
        //ie
        if (Browser.Version() < 8) 
        {
            t += 10;
            l += 10; 
        }        
    }
    else
    {
        //ff
    }
    
    obj.style.top = t + "px";
    obj.style.left = l + "px";
}

function MainMenuMouseOut(name)
{
    var obj = document.getElementById(name);
    
    if(obj)
    {
        obj.style.display = "none";
    }
}

function OpenCloseControl(th,name)
{
    var obj = document.getElementById(name);
    
    if(obj == null) return;
    
    if(th.src.indexOf('icon_-.gif') > -1)
    {
        obj.style.display = "none";
        th.src = th.src.replace('icon_-.gif','icon_+.gif');
    }
    else
    {
        obj.style.display = "";
        th.src = th.src.replace('icon_+.gif','icon_-.gif');
    }
}

function WindowOpen(page)
{
    window.open(page, 'hpch', 'scrollbars=yes fullscreen=yes');    
}

function GetMp3PlayerScript(path) 
{
    var script = new Array();    
    
    script.push("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' ");
    script.push("codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,");
    script.push("0,0,0' width='200' height='20' id='dewplayer' align='middle'>");
    script.push("<param name='allowScriptAccess' value='sameDomain' />");
    script.push("<param name='movie' ");
    script.push("value='http://www.hpch.org.tw/flash/dewplayer/dewplayer.swf?mp3=");
    //script.push("http://www.hpch.org.tw/File/DownloadFile.ashx?id=8b8fdaf4-9cc8-4ec0-a3da-7e311783a38a");
    script.push(path);
    script.push("&amp;bgcolor=FFFFFF&ampl;showtime=1&amp;autoreplay=1' />");
    script.push("<param name='quality' value='high' />");
    script.push("<param name='bgcolor' value='FFFFFF' />");
    script.push("<embed src='http://www.hpch.org.tw/flash/dewplayer/dewplayer.swf?mp3=");
    //script.push("http://www.hpch.org.tw/File/DownloadFile.ashx?id=8b8fdaf4-9cc8-4ec0-a3da-7e311783a38a");
    script.push(path);
    script.push("&amp;bgcolor=FFFFFF&ampl;showtime=1&amp;autoreplay=1' quality='high' ");
    script.push("bgcolor='FFFFFF' width='200' height='20' name='dewplayer' align='middle' ");
    script.push("allowScriptAccess='sameDomain' type='application/x-shockwave-flash'");
    script.push("pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object>");
    
    return script.join('');
}