// MyFunctions.js  for Canexcel Glass Inc. ,   Amethyst Design CA.
var flag=false;

function NoRightClick()
{
	if (navigator.appName.indexOf("Internet Explorer") != -1 || navigator.appName.indexOf("Netscape") != -1 || navigator.appName.indexOf("Mozilla") != -1 || navigator.appName.indexOf("Maxthon") != -1 || navigator.appName.indexOf("Avant") != -1 )
	    document.onmousedown = noSourceExplorer;
	function noSourceExplorer(){if (event.button == 2 | event.button == 3)
	{
		alert("Amethyst Design. All rights reserved.");}
	}
}


function PageAds(sWidth,sHeight)
{
	var iAdNum = 2;

	aAdItem=new Array(iAdNum);
  for(i=0;i<iAdNum;i++)
  {
	  aAdItem[i] = new Array(iAdNum);
 	}
  aAdItem[0]="CanexcelAd01.gif";
  aAdItem[1]="CanexcelAd01.gif";

	var sFlash = "null"; //"top.swf"; // 
	var imgLocal = "images/";
	var today = new Date();
	var num = today.getSeconds()% iAdNum;
	var str0;
	//var today=mydate.getDay()
	str0 = '<td width="'+sWidth+'" heignt="'+sHeight+'" align="right" cellpadding="0" cellspacing="0" bordercolor="#111111" style="border-collapse: collapse" background="'+imgLocal+aAdItem[num]+'"  alt="Welcome for Advertising" >';
	document.write(str0);
	if (sFlash != "null")
		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="'+sWidth+'" height="'+sHeight+'" align="middle"><param name="movie" value="'+imgLocal+sFlash+'"><param name="quality" value="high"><param name="wmode" value="transparent"><embed src="'+imgLocal+sFlash+'" width="'+sWidth+'" height="'+sHeight+'" align="middle" quality="high"  pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object>');
	document.write('</td>');
}


function int(I,k)
{
	//define variable
	var ff=0;
	var j;
	j=Math.round(I/k)-I/k;
	if (j>=0.5)
		ff=Math.round(I/k)-1;
	if (j<=0)
		ff=Math.round(I/k);
	return ff;
}


function DrawImage(ImgD,iwidth,iheight)
{
    //参数(图片,允许的宽度,允许的高度)
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0)
    {
        flag=true;
        if(image.width/image.height>= iwidth/iheight)
        {
            if(image.width>iwidth)
            {  
                ImgD.width=iwidth;
                ImgD.height=(image.height*iwidth)/image.width;
            }
            else
            {
                ImgD.width=image.width;  
                ImgD.height=image.height;
            }
    //        ImgD.alt=image.width+"×"+image.height;
        }
        else
        {
            if(image.height>iheight)
            {
                ImgD.height=iheight;
                ImgD.width=(image.width*iheight)/image.height;        
            }
            else
            {
                ImgD.width=image.width;  
                ImgD.height=image.height;
            }
//        ImgD.alt=image.width+"×"+image.height;
        }
    }
} 


