//**************************************************************************
//      filename : aNd1coderjsLib.js
//        author : aNd1coder
//        e-mail : aNd1coder@gmailcom
//   description : collection and arrange common javascript functions
//   create date : 2008/09/17
//**************************************************************************


//  function name : $(id)
//         author : aNd1coder
//    description : get the dom element'id
//    create date : 2008/09/17
//==================================================================
//arguments:
//          id  --- dom element'id
//==================================================================
function $$(id){
    document.getElementById(id);
}


//  function name : killErrors
//         author : aNd1coder
//    description : kill all the errors occur
//    create date : 2008/09/17

function killErrors() { 
return true; 
} 
window.onerror = killErrors; 


//  function name : fontZoom(targetElement,size)
//         author : aNd1coder
//    description : get the dom element'id
//    create date : 2008/09/17
//==================================================================
//arguments:
//          targetElement  --- dom element'id
//          size		   --- element' fontSize
//==================================================================
function fontZoom(targetElement,size){
        document.getElementById(targetElement).style.fontSize=size;
}


//  function name : PicsPriview(pWidth,pHeight,pSrc,pUrl,pAlt,pTime)
//         author : aNd1coder
//    description : for previewing products pictures 
//    create date : 2008/09/18
//==================================================================
//arguments:
//          width  --- picture width
//          height --- picture height
//          src    --- picture src (Array)
//          url    --- picture url (Array)
//          alt    --- picture alt (Array)
//          time   --- picture switch delay
//==================================================================
/*
function PicsPreview(pWidth,pHeight,pSrc,pUrl,pAlt,pTime){
    var srcCount = pSrc.length;
    this.width = pWidth;
    this.height = pHeight;
    var i = 0;
    function Switch(){
        this.src = pSrc;
        this.url = pUrl;
        this.alt = pAlt;
        this.time = pTime;
        if(i == srcCount){
            i = 0;
        }
        
        var currentPic = document.getElementById("currentPic");
        function setTransition(){
            if (document.all){
                currentPic.filters.revealTrans.Transition=Math.floor(Math.random()*23);
                currentPic.filters.revealTrans.apply();
            }
        }

        function playTransition(){
            if (document.all)
                currentPic.filters.revealTrans.play()
        }
        setTransition();
        currentPic.src = this.src[i];
        currentPic.alt = this.alt[i];
        document.getElementById("currentUrl").href = this.url[i];
        playTransition();
        i++;
        setTimeout(Switch,this.time);
    }
    this.show = function(){
        document.writeln("<a href='' id='currentUrl' ><img id='currentPic' alt='' src ='" + pSrc[0] + "' style='filter:revealTrans(duration=2,transition=20);border:none;' width='" + this.width + "' height='" + this.height+ "'/></a>");
        setTimeout(Switch,this.time);
    }
}
*/

//  function name : PicsSwitch(width,height,txtHeight,piclist,linklist,txtlist)
//         author : aNd1coder
//    description : for previewing pictures 
//    create date : 2008/09/18
//=============================================================================
//arguments:
//          width  --- flash width
//          height --- flash height
//          txtHeight    --- picture text height
//          piclist    --- pictures list   (format:p1|p2|p3);
//          linklist    --- picture links list  (format:l1|l2|l3)
//          txtlist   --- pictures texts list   (format:t1|t2|t3)
//=============================================================================
function PicsSwitch(width,height,txtHeight,piclist,linklist,txtlist,bgcolor){

    var focus_width=width;
    var focus_height=height;
    var text_height=txtHeight;
    var flash_url="images/banner.swf";
    var swf_height = focus_height+text_height

    var pics= piclist;
    var links= linklist;
    var texts= txtlist;

    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
    document.write('<param name="allowScriptAccess" value="sameDomain">');
    document.write('<param name="movie" value="'+flash_url+'">')
    document.write('<param name="quality" value="high">')
    document.write('<param name="bgcolor" value='+bgcolor+'>')
    document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
    document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
    document.write('<embed src="'+flash_url+'" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor='+bgcolor+' quality="high" width="'+ focus_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    document.write('</object>');
}

    

//  function name : OnlineService(width,qq,version,altqq/*,isMSN,MSN,altMsn*/)
//         author : aNd1coder
//    description : Online qq service
//    create date : 2008/09/19
//=============================================================================
//arguments:
//          width       --- panel width
//          qqlist      --- qq list
//          version     --- qq online service version(1-10)
//          alt         --- qq alt
//          extension   --- this can extension MSN and other online service
//=============================================================================
/*
function OnlineService(width,qqlist,version,alt,isMSN,MSN,altMsn){

    var online= new Array();
    var qlen = qqlist.length;
    //var mlen = MSN.length;
    
    if (!document.layers){document.write('<div id="divStayTopLeft" style="position:absolute">');}

    document.write('<layer id="divStayTopLeft"><table border="0" width="' + width + '" cellspacing="0" cellpadding="0">');
    document.write('<tr><td width="' + width + 'px"><img border=0 src="images/kefu_up.gif" alt=""/></td></tr>');
    document.write('<tr><td valign=middle  align="left" background="images/kefu_middle.gif"><table width="' + width + '">')
    for(var i =0;i<qlen;i++){
        document.write('<tr><td height="22" align="center" valign="middle" class="kehu" colspan="2">');
        document.write('<a  target="blank" href="tencent://message/?uin=' + qqlist[i] + '&amp;Site=www.szkunfu.com&amp;Menu=yes">');
        document.write('<img border="0" src="http://wpa.qq.com/pa?p=1:' + qqlist[i] + ':' + version + '" alt="' + alt + '" align="absmiddle" /></a></td></tr>');
    }
    if(isMSN){
        for(var j =0;j<countMSN-1;j++){
            document.write('<tr><td width="26px" height="22px" align="right" valign="middle" class="kehu">');
            document.write('<A href="msnim:chat?contact=' + MSN[j] + '"><img src="images/MSN.gif" width="14px" height="16px" border="0"></A></td>');
            document.write('<td height="20px" align="left" valign="middle" class="kehu"><A href="msnim:chat?contact=' + MSN[j] + '">' + altMsn[i] + '</A></td></tr>');
        }
    }
    document.write('</table></td></tr><tr><td valign=middle  align="center" background="images/kefu_middle.gif">&nbsp;</td></tr>');
    document.write('<tr><td width="' + width + 'px"><img border="0" src="images/kefu_down.gif" alt="" /></td></tr></table></layer>');

    var verticalpos="frombottom"
    if (!document.layers){document.write('</div>');}
    
    function JSFX_FloatTopDiv()
    {
        var adRightWidth =width;
        var marginLeft = 0;

	    var startX =((document.documentElement.clientWidth == 0)?document.documentElement.clientWidth:document.documentElement.clientWidth) - adRightWidth - marginLeft + 'px';
	    startY = 400;
	    var ns = (navigator.appName.indexOf("Netscape") != -1);
	    var d = document;
	    function ml(id)
	    {
		    var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		    if(d.layers)el.style=el;
		    el.sP=function(x,y){this.style.left=x;this.style.top=y;};
		    el.x = startX;
		    if (verticalpos=="fromtop")
		    el.y = startY;
		    else{
		    el.y = ns ? pageYOffset + innerHeight : document.documentElement.scrollTop + document.documentElement.clientHeight;
		    el.y -= startY;
		    }
		    return el;
	    }
	    window.stayTopLeft=function()
	    {
		    if (verticalpos=="fromtop"){
		    var pY = ns ? pageYOffset : document.documentElement.scrollTop;
		    ftlObj.y += (pY + startY - ftlObj.y)/8;
		    }
		    else{
		    var pY = ns ? pageYOffset + innerHeight : document.documentElement.scrollTop + document.documentElement.clientHeight;
		    ftlObj.y += (pY - startY - ftlObj.y)/8;
		    }
		    ftlObj.sP(ftlObj.x, ftlObj.y);
		    setTimeout("stayTopLeft()", 10);
	    }
	    ftlObj = ml("divStayTopLeft");
	    stayTopLeft();
    }
    JSFX_FloatTopDiv();
}
*/

//  function name : flash(url,w,h,wmode)
//         author : aNd1coder
//    description : html page inline-flash
//    create date : 2008/09/19
//=============================================================================
//arguments:
//          url    --- falsh location url
//          w      --- falsh width
//          h      --- falsh height
//          wmode  --- falsh mode eg:transparent or ""
//=============================================================================
function flash(url,w,h,wmode){
    document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
    document.write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"');
    document.write(' WIDTH='+w+' HEIGHT='+h+'>');
    document.write(' <PARAM NAME=movie VALUE="'+url+'"> '); 
    document.write(' <PARAM NAME=quality VALUE=autohigh> ');
    document.write(' <PARAM NAME=wmode VALUE='+wmode+'> '); 
    document.write(' <EMBED SRC="'+url+'" QUALITY=autohigh wmode='+wmode); 
    document.write(' NAME=flashad swLiveConnect=TRUE WIDTH='+w+' HEIGHT='+h);
    document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">');
    document.write('</EMBED>');
    document.write('</OBJECT>');
}

//  function name : flvplay(url,w,h,domain)
//         author : aNd1coder
//    description : html page inline-flash
//    create date : 2008/09/19
//=============================================================================
//arguments:
//          url    --- falsh location url
//          w      --- falsh width
//          h      --- falsh height
//          wmode  --- falsh mode eg:transparent or ""
//=============================================================================
function flvplay(url,w,h,domain){
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+w+'" height="'+h+'">');
    document.write('<param name="movie" value="js/Flvplayer.swf?vcastr_file=http://'+domain+'/'+url+'&LogoText=" />');
    document.write('<param name="quality" value="high" />');
    document.write('<param name="allowFullScreen" value="true" /> '); 
   document.write(' <param name="FlashVars" value="vcastr_file=indexvideo.flv&IsAutoPlay=1" />');
    document.write('<param name="FlashVars" value="vcastr_file=http://'+domain+"/"+url+'&LogoText=www.efes -cn.com&BufferTime=3" /> ');
    document.write('<embed src="js/Flvplayer.swf?vcastr_file=http://'+domain+'/'+url+'&LogoText=" allowfullscreen="true"  quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'"> '); 
    document.write('</embed>');
    document.write('</object>');
}


/*function flvplay(url,w,h,domain){
     document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+w+'" height="'+h+'">');
     document.write('<param name="movie" value="vcastr.swf?vcastr_file=http://'+domain+'/'+url+'">');
     document.write('<param name="quality" value="high">');
     document.write('<embed src="vcastr.swf?vcastr_file=http://'+domain+'/'+url+'&LogoText=www.efes-cn.com" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'"></embed></object>');
}
*/

//  function name : Thumbnail(ImgD,w,h)
//         author : aNd1coder
//    description : set the pictures height and width to prevent it to breaking the page
//    create date : 2008/09/18
//======================================================================================
//arguments:
//          ImgD  --- picture url
//             w  --- picture Thumb width
//             h  --- picture Thumb height
//======================================================================================


function Thumbnail(ImgD,w,h){
    var flag = false;
    var image = new Image();
    image.src = ImgD.src;
    if(image.width > 0 && image.height > 0){
        flag = true;
        if(image.width/image.height > w/h){
            if(image.width > w){
                ImgD.width = w;
                ImgD.height = (image.height*w)/image.width;
                ImgD.style.display = "block";
            }else{
                ImgD.width = image.width;
                ImgD.height = image.height;
                ImgD.style.display = "block";
            }
        }else{
            if(image.height > h){
                ImgD.height = h;
                ImgD.width = (image.width*h)/image.height;
                ImgD.style.display ="block";
            }else{
                ImgD.width = image.width;
                ImgD.height = image.height;
                ImgD.style.display = "block";
            }
         }
    }
}

//videoURL为视频名称,webURL为视同儿戏频所在的网络地址
function changeShowVideo(ID)
{
    document.getElementById("ctl00_ContentPlaceHolder1_ichangesFlv").src="changesFlv.aspx?id=" +ID+"&r="+Math.random(); 
}

function onchageImg(imgURL,ltTitle)
{
    var divShowVideo=document.getElementById("imgShowStores");
    divShowVideo.src= imgURL;
    document.getElementById("ltTitle").innerHTML=ltTitle;
}
