/*
A pWidgets Bit...
website: www.pwidgets.com
*/


pWidgetsFOID = new Object();
pWidgetsFTID = new Object();

function pWidgets(object, destOp, rate, delta){
	if (!document.all) return
    if (object != "[object]"){
        setTimeout("pWidgets("+object+","+destOp+","+rate+","+delta+")",0);
        return;
    }
        
    clearTimeout(pWidgetsFTID[object.sourceIndex]);
    
    diff = destOp-object.filters.alpha.opacity;
    direction = 1;
    if (object.filters.alpha.opacity > destOp){
        direction = -1;
    }
    delta=Math.min(direction*diff,delta);
    object.filters.alpha.opacity+=direction*delta;

    if (object.filters.alpha.opacity != destOp){
        pWidgetsFOID[object.sourceIndex]=object;
        pWidgetsFTID[object.sourceIndex]=setTimeout("pWidgets(pWidgetsFOID["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
    }
}


var imgObj, aNewWin;
function checkImg(theURL,winName){
	// 對象是否已創建
	if (typeof(imgObj) == "object")
	{
		// 是否已取得了圖像的高度和寬度
		if ((imgObj.width != 0) && (imgObj.height != 0))
		// 根據取得的圖像高度和寬度設置彈出窗口的高度與寬度，並打開該窗口
		// 其中的增量 20 和 30 是設置的窗口邊框與圖片間的間隔量
			OpenFullSizeWindow(theURL,winName, ",width=" + (imgObj.width+20) + ",height=" + (imgObj.height+30));
		else
			// 因為通過 Image 對像動態裝載圖片，不可能立即得到圖片的寬度和高度，所以每隔100毫秒重複調用檢查
			setTimeout("checkImg('" + theURL + "','" + winName + "')", 500)
	}
}
var newWindow;
function OpenFullSizeWindow(theURL)
{
	// 如果視窗不存在，就建立一個並開啟它
	if ((!newWindow) || newWindow.closed)
	{
		newWindow = window.open(theURL, "cart", "toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no, height=300, width=500");
	}
	else
	{
		// 如果視窗已經存在，就直接顯示他
		newWindow.location.href=theURL;
		newWindow.focus();
	}
}



function fnCallDialog(url, width, height) {
	//alert(width);	
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		window.showModelessDialog(url,window,'resizable: no; scroll:yes; status:false;dialogWidth:' + width + 'px;dialogHeight:' + height + 'px');
	}
	else
	{
		//alert('jackie');
		var txt,n,p,w,h
		n="Product_Image"
		p=url
		txt="newWin=window.open('" + p + "','" + n + "','Width=' + width + ',Height=' + height + ', scrollbars=yes')"
		//alert(txt);
		eval(txt)
		newWin.moveTo((screen.availWidth-w)/2,(screen.availHeight-h)/2)
		newWin.focus()
	}

	
}

