//==format button==
//c is original className
//cOver is the className onmouseover
function formatButtonClass(c){
    var inputs = document.getElementsByTagName("input");
	var len = inputs.length;
	for (var i=0; i < len; i++){
		if (inputs[i].className == ""){
			if (inputs[i].type=='submit' || inputs[i].type =='button'){
			    inputs[i].className = c;
			    inputs[i].onmouseover = function(){
			        showBtnOver(this);
			    }
			    inputs[i].onmouseout = function(){
			        showBtnOut(this);
			    }				    
			}				
		}
	}
}
function showBtnOver(obj){
	if(obj.className.indexOf("Over")==-1)
		obj.className=obj.className+"Over";
}

function showBtnOut(obj){
	if(obj.className.indexOf("Over")>-1)
		obj.className=obj.className.replace("Over","");
}
//==formatInputClass==
//c is className
function formatInputClass(c){
	var inputs = document.getElementsByTagName("input");
	var len = inputs.length;
	for (var i=0; i < len; i++){
		if (inputs[i].className == ""){
			if (inputs[i].type=='text' || inputs[i].type =='password')
				inputs[i].className = c;
		}
	}
	var textareas = document.getElementsByTagName("textarea");
	len = textareas.length;
	for (i = 0; i < len; i++){
		if (textareas[i].className == ""){
			textareas[i].className = c
		}
	}	
}
// JavaScript Document
//swapPic(showPicID,imgSrc1,imgSrc2[,imgSrc3[,imgSrc4]])
function swapPic(showPicID){	
    var argLen = arguments.length;
    var imgObj = document.getElementById(showPicID);   
    if(argLen > 2){
        var flag = 0;
        for(var i=1;i<argLen; i++){
            if(flag == 1){
				imgObj.parentNode.style.background = 'url(images/css/loading.gif) no-repeat center center';
				var tmpImg = new Image();
				tmpImg.onload = function(){
					imgObj.parentNode.style.background = "";
					imgObj.src = this.src;	
					document.getElementById("linkDownProductPic").href = this.src;					
					//setTimeout("fixMinHeight('righter','lefter', 450);",200)//function in main.js
				}
				tmpImg.onerror = function(){
					imgObj.parentNode.style.background = "";
					imgObj.src = this.src;	
					document.getElementById("linkDownProductPic").href = this.src;							
				}
				tmpImg.src = arguments[i];              
                break;
            }
            if(imgObj.src.toLowerCase().indexOf(arguments[i].toLowerCase())!= -1){
                flag = 1;
            }
            if(i==argLen-1){
                i = 0;
                flag = 1;
            }
        }
    }	
}
//use in foot control
function fixMinHeight(id,id2, minHeight){
//    var tmpH = document.getElementById(id).scrollHeight; 
//    if(!!document.getElementById(id2)){        
//        tmpH = Math.max(tmpH, document.getElementById(id2).scrollHeight+80);        
//    }
//    var tmpH2 = Math.max(document.documentElement.scrollHeight,document.documentElement.clientHeight);
//    tmpH2 = tmpH2-140-55;
//    //tmpH = Math.max(tmpH,minHeight) 
//    tmpH  = Math.max(tmpH, tmpH2);
//    document.getElementById(id).style.height = tmpH + "px";
//    try{document.getElementById(id2).style.height = tmpH + "px";}catch(e){}
}
function cachBackImg(imgName){
    var picBack = new Image();
    picBack.onload = function(){document.getElementById("linkPicBack").style.visibility="visible";}
    picBack.src="admin/YX_UpFile/BigAttach/"+imgName;
}
function showBtnOver(obj){
	if(obj.className.indexOf("Over")==-1)
		obj.className=obj.className+"Over";
}

function showBtnOut(obj){
	if(obj.className.indexOf("Over")>-1)
		obj.className=obj.className.replace("Over","");
}
function G(id){
    return document.getElementById(id);
}
/*
function formatInputClass(c){
	var inputs = document.getElementsByTagName("input");
	var len = inputs.length;
	for (var i=0; i < len; i++){
		if (inputs[i].className == ""){
			if (inputs[i].type=='text' || inputs[i].type =='password')
				inputs[i].className = c;
		}
		if(inputs[i].type == "button"){
		    inputs[i].onmouseover = function() {
		        if (this.className.indexOf("Over")==-1)	this.className=this.className+"Over";
		    }
		    inputs[i].onmouseout = function() {
		        this.className = this.className.replace("Over","")
		    }
		}
	}
	var textareas = document.getElementsByTagName("textarea");
	len = textareas.length;
	for (i = 0; i < len; i++){
		if (textareas[i].className == ""){
			textareas[i].className = c
		}
	}	
}*/
function formatLinkFocus(ID){
	var links;
	if(!!ID){
		links = document.getElementById(ID).getElementsByTagName("a");
	}else{
		links = document.getElementsByTagName("a");	
	}
	for (var i=0; i<links.length; i++){
		links[i].onfocus = function () {
			this.blur();
		}
	}
}
//ulid, url1, url2
function formatCurNavLink(){
	var navLinks, navLinkHref, j;	
	var locationHref = new Array()
	locationHref[0] =  new String();
	locationHref[1] =  new String();	
	navLinks = document.getElementById(arguments[0]).getElementsByTagName("a");	
	if(arguments.length > 1){
		locationHref = arguments;		
	}else{		
		locationHref[1] = window.location.href.toLowerCase();
		locationHref[1] = locationHref[1].substr(locationHref[1].lastIndexOf("/")+1)
		locationHref[1] = locationHref[1] == "" ? "default.asp" : locationHref[1];		
	}	
	for(var i=0; i<navLinks.length; i++){	
		navLinkHref = navLinks[i].href.toLowerCase();		
		navLinkHref = navLinkHref.substr(navLinkHref.lastIndexOf("/")+1);
		//navLinkHref = navLinkHref.replace(/#/, "");					
		for(j=1; j<locationHref.length; j++){
			var linkImg;
			if(navLinkHref.indexOf("#") == -1 && locationHref[j].toLowerCase() == navLinkHref) {
			    if(navLinks[i].getAttribute("name")=="ImgA"){
			        navLinks[i].name = "";
			        setBackground(navLinks[i]);
			    }
				linkImg = navLinks[i].getElementsByTagName("img");
				if (linkImg.length > 0){					
					//linkImg[0].onmouseover = function (){};
					//linkImg[0].onmouseout = function (){};
					defLiObj = navLinks[i].parentNode;
					setOn(defLiObj,false);
				}
				navLinks[i].className = "c"					
			}			
		}	
	}	
}
//==fomatLeftNav begin==
//var isIe = /msie/i.test(navigator.userAgent); 
function fomatLeftNav(id){
    var links = document.getElementById(id).getElementsByTagName("a");
    for(var i=0;i<links.length; i++){
        if(links[i].getAttribute("name")=="ImgA"){
            var tmpImg=new Image();
            tmpImg.src = swapImgSrc(getImg(links[i])[0], getImg(links[i])[1]);
            links[i].onmouseover = function() {
                setBackground(this)
            }
            links[i].onmouseout = function(){
		        setBackground(this)
	        }
        }
    }
}
function formatArrow(id){
    var spanObjs = document.getElementById(id).getElementsByTagName("span");
    for(var i=0;i<spanObjs.length;i++){
        if(spanObjs[i].parentNode.getElementsByTagName("ul").length>0){
            spanObjs[i].title = "expand";
            spanObjs[i].onclick = function(){
                showSub(this);
            }
        }        
    }
}
function showSub(obj){
    if(obj.title=="expand"){
        obj.title = "collapse";
        obj.className = "expand";
        obj.parentNode.className += " expand";
        //setTimeout("fixMinHeight('righter','lefter', 450);",200)
    }
    else{
        obj.title = "expand";
        obj.className = "collapse";
        obj.parentNode.className = obj.parentNode.className.replace("expand", "");
        //setTimeout("fixMinHeight('righter','lefter', 450);",200)
    }
}
function showSub2(parentNodeObj)
{
    if(document.all.ordertrack){
        if(parentNodeObj.getElementsByTagName("span").length>0){
            showSub(parentNodeObj.getElementsByTagName("span")[0]);
        }
    }
}
function formatCurLeftNav(id, cid){
    var links = document.getElementById(id).getElementsByTagName("a");
    for(var i=0;i<links.length; i++){
        if(links[i].href.toLowerCase().indexOf("cid=" + cid)!=-1){
            setBackground(links[i]);
            links[i].onmouseover = function() {}
            links[i].onmouseout = function() {}
        }
    }
}
function formatCurMenu(id){
    var links = document.getElementById(id).getElementsByTagName("a");
    var locationUrl = window.location.href.toLowerCase();
    for(var i=0;i<links.length;i++){
        if(links[i].href.toLowerCase()==locationUrl){
            links[i].className = "c";
            links[i].parentNode.className = "c";
            break;
        }
    }
}
function formatNewCurLeftNav(id,otherID,isExpand){ 
    if(!!otherID){
        document.getElementById(otherID).className="c";
        if(!!isExpand){
           showSub2(document.getElementById(otherID).parentNode.parentNode.parentNode);
        }                    
        return ;
    }    
    if(!!document.getElementById("drc")&&document.getElementById("drc").getElementsByTagName("a").length>=2){                
        var links = document.getElementById("drc").getElementsByTagName("a");
        var leftLinks = document.getElementById(id).getElementsByTagName("a");
        for(var i=0;i<leftLinks.length;i++){
            for(var j=0;j<links.length;j++){
                if(links[j].href.toLowerCase()==leftLinks[i].href.toLowerCase()){
                    leftLinks[i].className="c";
                    if(leftLinks[i].id.indexOf("sub")!=-1){
                        leftLinks[i].parentNode.parentNode.parentNode.className="c";
                        showSub2(leftLinks[i].parentNode.parentNode.parentNode);
                        leftLinks[i].parentNode.parentNode.parentNode.getElementsByTagName("a")[0].className="c";
                    }else if(!!isExpand){
                        showSub2(leftLinks[i].parentNode);
                    }                    
                }
            }
        }
    }
    else
    {    
        var curUrl = window.location.href.toLowerCase();
        if(curUrl.indexOf("&msg=")!=-1){
		    curUrl = curUrl.substr(0,curUrl.lastIndexOf("&msg="));
		}
        var links = document.getElementById(id).getElementsByTagName("a");
        for(var i=0;i<links.length; i++){
            if(links[i].href.toLowerCase()==curUrl){
                links[i].className="c";                
                if(links[i].id.indexOf("sub")!=-1){
                    links[i].parentNode.parentNode.parentNode.className="c expand";
                    links[i].parentNode.parentNode.parentNode.getElementsByTagName("span")[0].title="collapse";//ÐÞ¸Ä(2009-11-10)
                    links[i].parentNode.parentNode.parentNode.getElementsByTagName("span")[0].className="expand";//ÐÞ¸Ä(2009-11-10)
                    showSub2(links[i].parentNode.parentNode.parentNode);
                    links[i].parentNode.parentNode.parentNode.getElementsByTagName("a")[0].className="c";
                }else if(!!isExpand){
                        links[i].parentNode.className="c";
                        showSub2(links[i].parentNode);
                }else{
                    links[i].parentNode.className="c";
                }
                break;
            }
        }    
    }
}

function getImg(Obj){
    var tmp, imgExt;
    try{
        tmp = Obj.style.filter;  
        tmp = tmp.replace(/.*src=\'/g, "");                
        tmp = tmp.substring(0,tmp.indexOf("'"));                
        imgExt = tmp.substr(tmp.lastIndexOf(".")+1);                
    } catch(e){
        tmp = Obj.style.backgroundImage;
        tmp = tmp.toLowerCase().replace("url(","");
        tmp = tmp.toLowerCase().replace(")","");
        imgExt = tmp.substr(tmp.lastIndexOf(".")+1)
    } 
    return [tmp,imgExt];
}
function swapImgSrc(tmp, imgExt){
	if(tmp.indexOf("_onmouseover")==-1){
         tmp = tmp.replace("."+imgExt,"_onmouseover."+imgExt);
    }else{
       tmp = tmp.replace("_onmouseover","");
    }    
    return tmp;   
}
function setBackground(Obj){ 
	if(isIe){  
	    Obj.style.filter = swapImgSrc(Obj.style.filter,getImg(Obj)[1])		
	}
	Obj.style.backgroundImage = swapImgSrc(Obj.style.backgroundImage,getImg(Obj)[1]);
}
//==fomatLeftNav end==

//formatNav begin
var defLiObj;
function setOn(liObj,displaySubMenu){
	var tmpSrc;
	if(!liObj) return;
	if(displaySubMenu!=false) liObj.className += " iehover";	
}
function setOff(liObj){
	var tmpSrc;
	if(!liObj) return;
	liObj.className = liObj.className.replace(/iehover/g,"")	
}
function clearAll(id){
	var lis = document.getElementById(id).getElementsByTagName("li");
	for(var i=0; i<lis.length; i++){
		lis[i].className = lis[i].className.replace(/iehover/g, "");		
	}
}
var t1,t2, tmpObj;
function formatNav(id){
	tmpID = id;
	var img = new Array();	
	var NavImg = G(id).getElementsByTagName("li");		
	for (var i=0; i<NavImg.length; i++){	    
	    NavImg[i].onmouseover = function(){
	        //clearTimeout(t1);
	        //clearTimeout(t2);
	        clearAll(id);
	        setOn(this);	
	        //setLiAStyleBg(this)           	           
	    }
	    NavImg[i].onmouseout = function(){
	        tmpObj = this;
	        setOff(tmpObj)    
	        //t1 = setTimeout("setOff(tmpObj)", 1000);
	        //t2 = setTimeout("setOn(defLiObj, false)", 1000);
	        //setLiAStyleBg(this)
	    }		
	}
}
function setLiAStyleBg(liObj){
    var links = liObj.getElementsByTagName("a")
    for(var j=0;j<links.length;j++)
    {
        if(links[j].getAttribute("name")=="ImgA"){
            var tmpImg=new Image();
            tmpImg.src = swapImgSrc(getImg(links[j])[0], getImg(links[j])[1]);
            setBackground(links[j]);
            break;
        }
    }	     
}
    

nereidFadeObjects = new Object();
nereidFadeTimers = new Object();
var isIe = /msie/i.test(navigator.userAgent); 
function nereidFade(object, destOp, rate, delta){	
	//if (!document.all) return;
    if (object != "[object]"){  //do this so I can take a string too
        setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
        return;
    }
    clearTimeout(nereidFadeTimers[object.sourceIndex]);
	var curOp = getOpecity(object);
    diff = destOp-curOp;
    direction = 1;
    if (curOp > destOp){
        direction = -1;
    }
    delta=Math.min(direction*diff,delta);
    setOpecity(object, curOp + direction*delta);
    if (curOp != destOp){
        nereidFadeObjects[object.sourceIndex]=object;
        nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
    }
}
function getOpecity(o){
	var opacity;
	opacity = isIe ? o.filters.alpha.opacity : o.style.opacity;		
	return opacity < 1 ? parseInt(opacity * 100, 10) : opacity;		
}
function setOpecity(o, opacity){		
	var tmp = opacity;	
	if(isIe){					
		o.style.filter = "Alpha(Opacity=" + tmp + ")";
	}else{
		tmp = tmp / 100;			
		o.style.opacity = tmp;
	}
}
//formatNav end

//for showmsgBox
//1
var boxDivWidth = 300
var boxDivHeight = 170;
var box_innerHTML = new Array('<div style="height:142px;position:relative;padding:28px 30px 0 30px;text-align:certer;"><table valign="top"><tr><td style="text-align:center;vertical-align:middle;height:90px;line-height:25px">','</td></tr><div style="position:absolute;bottom:25px;left:0;width:100%;text-align:center;"><input type="button" onmouseout="showBtnOut(this)" onmousemove="showBtnOver(this)" class="submitMiniGreen" id="Button3" onclick=\"','\" value="OK" />', '</div></div>');

function CustomBtnYes(text){
    var arrCustomYes = new Array('<div style="height:142px;position:relative;padding:28px 30px 0 30px;text-align:certer;"><table valign="top"><tr><td style="text-align:center;vertical-align:middle;height:90px;line-height:25px">','</td></tr><div style="position:absolute;bottom:25px;left:0;width:100%;text-align:center;"><input type="button" onmouseout="showBtnOut(this)" onmousemove="showBtnOver(this)" class="submitMiniGreen" id="Button3" onclick=\"','\" value="'+text+'" />', '</div></div>');    
    return arrCustomYes;
}

//1 function
//a.showbox(boxContent) b.showbox(boxContent,url) c. showbox(boxContent,url,isConfirmType) d.popbox(boxContent,url,isConfirmType,buttonID)
function showbox(boxContent,url,isConfirmType, buttonID)
{		
	popCoverDiv();
	if(!!url&&!!isConfirmType&&!!buttonID&&isConfirmType==true){
	    popbox(boxContent,url,isConfirmType,buttonID);
	}else if (!!url&&!!isConfirmType&&isConfirmType==true){
	    popbox(boxContent,url,isConfirmType);
	}else if(!!url){
	    popbox(boxContent,url);
	}else{
	    popbox(boxContent);
	}	
}

function CustomShowBox(boxContent,url,isConfirmType,YseText,NoText)
{		
	popCoverDiv();
	CustomPopBox(boxContent,url,isConfirmType,YseText,NoText);
}

function showJumpBox(boxContent, url)
{	
	popCoverDiv();
	popbox(boxContent,url);
}
function popbox(boxContent,url,isConfirmType,buttonID)
{
  var strTmp;
  strTmp = !!url&&url!=""? "location.href='"+ url +"';" :"closeBox(\'box_div\',true);"
  strTmp = !!buttonID? "document.getElementById('" + buttonID + "').click();" : strTmp; 
  if (G("box_div")) {
   G("box_div").style.display = '';
  } else {
   var boxDiv = GC('div');
   document.body.appendChild(boxDiv);
   boxDiv.id = 'box_div';
   }
   G("box_div").align = "center";   
   with (G("box_div").style) {
    position = 'absolute';    
    width = boxDivWidth + 'px';
    height = boxDivHeight + 'px';
    zIndex = 302;
    //background = 'url(images/alertBoxBG.gif)';    
    //border = '#66CCFF solid 1px';closeBox(\'box_div\');
   }  
  middleClientWindow(G("box_div"));
  G("box_div").innerHTML = box_innerHTML[0]+boxContent+box_innerHTML[1]+ strTmp +box_innerHTML[2] + (!!isConfirmType? ' <input type="button" onmouseout="showBtnOut(this)" onmousemove="showBtnOver(this)" class="submitMiniGreen" id="Button3" onclick=\"closeBox(\'box_div\');\" value="Cancel" />' : "") + box_innerHTML[3];
}

function CustomPopBox(boxContent,url,isConfirmType,YesText,NoText,buttonID)
{
  var strTmp;
  strTmp = !!url&&url!=""? "location.href='"+ url +"';" :"closeBox(\'box_div\',true);"
  strTmp = !!buttonID? "document.getElementById('" + buttonID + "').click();" : strTmp; 
  if (G("box_div")) {
   G("box_div").style.display = '';
  } else {
   var boxDiv = GC('div');
   document.body.appendChild(boxDiv);
   boxDiv.id = 'box_div';
   }
   G("box_div").align = "center";   
   with (G("box_div").style) {
    position = 'absolute';    
    width = boxDivWidth + 'px';
    height = boxDivHeight + 'px';
    zIndex = 302;
    //background = 'url(images/alertBoxBG.gif)';    
    //border = '#66CCFF solid 1px';closeBox(\'box_div\');
   }  
  middleClientWindow(G("box_div"));
  var arrCustomBtnYes = CustomBtnYes(YesText)
  if(isConfirmType==true){
    G("box_div").innerHTML = arrCustomBtnYes[0]+boxContent+arrCustomBtnYes[1]+ strTmp +arrCustomBtnYes[2] + ' <input type="button" onmouseout="showBtnOut(this)" onmousemove="showBtnOver(this)" class="submitMiniGreen" id="Button3" onclick=\"closeBox(\'box_div\');\" value="'+NoText+'" />' + arrCustomBtnYes[3];
  }
  else{
    G("box_div").innerHTML = arrCustomBtnYes[0]+boxContent+arrCustomBtnYes[1]+ "closeBox(\'box_div\');" +arrCustomBtnYes[2] +  ' <input type="button" onmouseout="showBtnOut(this)" onmousemove="showBtnOver(this)" class="submitMiniGreen" id="Button3" onclick=\"'+strTmp+'\" value="'+NoText+'" />' + arrCustomBtnYes[3];
  }
  
}
function middleClientWindow(Obj){
   var bodyWidth = document.documentElement.offsetWidth;
   bodyWidth = bodyWidth > 800 ? bodyWidth : 800;
   var bodyHeight =  document.documentElement.clientHeight;
   bodyHeight = bodyHeight > 500 ? bodyHeight: 500;
   with(Obj.style){
        left = (bodyWidth- boxDivWidth)/2 + document.documentElement.scrollLeft + 'px';
        top = (bodyHeight- boxDivHeight)/2 + document.documentElement.scrollTop + 'px';
    }
}
function popCoverDiv()
{
  if (G("cover_div")) {
    G("cover_div").style.display= '';
  } else {
  var coverDiv = GC('div');
  document.body.appendChild(coverDiv);
  coverDiv.id = 'cover_div';
	with(coverDiv.style) {
	  position = 'absolute';
	  background = '#CCCCCC';
	  left = '0px';
	  top = '0px';
	  var bodySize = getBodySize();
	  width = bodySize[0] + 'px'
	  height = bodySize[1] + 'px';
	  zIndex = 301;
		if (isIE()) {
		  filter = "Alpha(Opacity=60)";
		} else {
		  opacity = 0.6;
		}
     }
  }  
}
function GC(t)
{
	return document.createElement(t);
}
function isIE()
{
	return (document.all && window.ActiveXObject && !window.opera) ? true : false;
} 
function getBodySize()
{
  var bodySize = [];
  with(document.documentElement) {
   bodySize[0] = (scrollWidth>clientWidth)?scrollWidth:clientWidth;  
   bodySize[1] = (scrollHeight>clientHeight)?scrollHeight:clientHeight;
  }
  bodySize[0] = bodySize[0]>800? bodySize[0] : 800;
  bodySize[1] = bodySize[1]>600? bodySize[1] : 600;
  return bodySize;
} 
function closePopCoverDiv(){
	if (G("cover_div")) {
    	G("cover_div").style.display = 'none';
	}
}
function closeBox(ID,returnValue){
	G(ID).style.display="none";
	closePopCoverDiv();
	return !!returnValue? returnValue : "";
}

//zoom Begin
isIe = /msie/i.test(navigator.userAgent);

var z, d; //z: auto generation; d: auto/manu generation;
var zoomID = "zoomDiv";
var zoomOpacity = 50;
var zoomBorder = "solid 1px #CCCCCC"; //border width must be 1px

//if detailDiv is already exist in page, follow define don't effect
var detailID = "detailDiv";
var detailW = 300;
var detailH = 300;
var detailBorder = "solid 1px #CCCCCC";
var marginHorizon = 10;
var drcFlag = 0; //0: auto; 1: left; 2: right;

var loadingImg = new Image();
loadingImg.src = "../images/css/loading.gif";

//picID
function initial(picDivID){
	//initrial zoomDiv
	if(!G(picDivID))return;
	z = creatNode(zoomID, "div", false);
	with(z.style){
		background = "#FFFFFF";
		border = zoomBorder;		
		position = "absolute";
		zIndex = 999;
		cursor = "pointer"
	}
	setOpecity(z, zoomOpacity);	
	
	//initrial detailDiv	
	d = creatNode(detailID, "div", false);	
	if(d.style.width==""){//for decide float or fix
		with(d.style){
			background = "#FFFFFF";			
			width = detailW + "px";
			height = detailH + "px";
			border = detailBorder;
			position = "absolute";
			overflow = "hidden";			
			zIndex = 1000;					
		}
	}
	
	
	z.onmouseover = function(){		
		display('block')
	};	
	z.onmouseout = function(){		
		display('none')
	}	
	G(picDivID).onmousemove = function(event){		
		event = window.event || event;
		showDetail(this, event)
	};	
	G(picDivID).onmouseout = function(){			
		display('none')
	}	
		
	//cach big images
}
function display(dspStr){
	d.style.display = dspStr;
	z.style.display = dspStr;
}
function showDetail(imgObj, event){		
	var smallImg = imgObj;			
	event = event?event:window.event;
	eX = event.clientX + document.documentElement.scrollLeft;
	eY = event.clientY + document.documentElement.scrollTop;	
	
	//show detailDiv
	var p = divPositon(smallImg, detailW, detailH, marginHorizon, drcFlag);
	with(d.style){
		display = "block";
		top = p[0] + "px";
		left = p[1] + "px";
	}	
	
	//showLoading
	var bigImg = new Image();
	d.style.background = "url("+ loadingImg.src +") no-repeat center center";	
	
	//cach big image	
	bigImg.onload = function() {
		var znW = bigImg.width / smallImg.clientWidth;
		var znH = bigImg.height / smallImg.clientHeight;
		var zoomW = detailW/znW;
		var zoomH = detailH/znH;		
		var zp = setZoomDivPosition(smallImg, z, zoomW, zoomH, eX, eY);
		d.style.background = "#FFFFFF"; 
		d.innerHTML = "<img src=\"" + bigImg.src + "\" />";	
		var innerImg = d.getElementsByTagName("img")[0];
		 
		innerImg.style.marginTop = -1*(zp[0]*znH>bigImg.height-detailH?bigImg.height-
detailH:zp[0]*znH) + "px";
		innerImg.style.marginLeft = -1*(zp[1]*znW>bigImg.width-detailW?bigImg.width-
detailW:zp[1]*znW) + "px";		
	}
	bigImg.onerror = function() {
		d.style.background = "";
		d.innerHTML = 'sorry! Load error.'
		setTimeout("d.style.display = 'none';", 1000)
	}	
	bigImg.src = smallImg.getAttribute("bigPic")||smallImg.src;		
	
	
}
function setZoomDivPosition(smallImg, z, zoomW, zoomH, eX, eY){
	var zp = new Array();
	var zT = eY - zoomH/2;
	var zL = eX- zoomW/2;	
	var sp = objPosition(smallImg);
	zT = zT < sp[0]-1? sp[0]-1 : zT;
	zT = zT > sp[0]+smallImg.clientHeight-1-zoomH? sp[0]+smallImg.clientHeight-1-zoomH : 
zT;
	zL = zL < sp[1]-1? sp[1]-1 : zL;
	zL = zL > sp[1]+smallImg.clientWidth-1-zoomW? sp[1]+smallImg.clientWidth-1-zoomW : zL;
	zoomW = zoomW > smallImg.clientWidth? smallImg.clientWidth : zoomW;
	zoomH = zoomH > smallImg.clientHeight? smallImg.clientHeight : zoomH;
	with(z.style){
		display = "block";
		width = zoomW + "px";
		height = zoomH + "px";
		top = zT + "px";
		left = zL + "px";		
	}	
	zp[0] = zT - sp[0]+1;
	zp[1] = zL - sp[1]+1;
	return zp;
}
function creatNode(ID, Tag, isDisplay){
	var o;
	if (document.getElementById(ID)) {
		o = document.getElementById(ID);
	} else {
		o = document.createElement(Tag);
		document.body.appendChild(o);
		o.id = ID; 	
	}	
	o.style.display = 'block';
	if(!isDisplay)o.style.display = 'none';  
	return o;
}
//function G(id){
//	return document.getElementById(id);
//}
//function setOpecity(o, opacity){		
//	var tmp = opacity;
//	if(isIe){			
//		o.style.filter = "Alpha(Opacity=" + tmp + ")";
//	}else{
//		tmp = tmp / 100;			
//		o.style.opacity = tmp;
//	}
//}
function objPosition(obj){
	var offset = new Array();
	offset[0] = obj.offsetTop + obj.clientTop;	
	offset[1] = obj.offsetLeft + obj.clientLeft;	
	while( obj = obj.offsetParent ){	
		offset[0] += obj.offsetTop  + obj.clientTop;		
		offset[1] += obj.offsetLeft + obj.clientLeft;	
	}	
	return offset;
}
function divPositon(obj,DivWidth, DivHeight, DivInterval, pFlag){
	var divP = new Array();
	var top;
	var p = objPosition(obj);
	if ((!!pFlag && pFlag == 1 ) || (!pFlag && p[1] >= DivWidth + DivInterval)){
		divP[0] = p[0] - DivHeight/2 + obj.offsetHeight/2
		divP[1] = p[1] - DivInterval - DivWidth;
		divP[2] = 1 //position flag: left
	}else{
		divP[0] = p[0] - DivHeight/2 + obj.offsetHeight/2
		divP[1] = p[1] + obj.offsetWidth + DivInterval;
		divP[2] = 2 //position flag: right
	}
	divP[0] = divP[0] < 0? 0 :divP[0];
	divP[0] = divP[0] < document.documentElement.scrollTop? 
document.documentElement.scrollTop: divP[0];
	return divP;
}
//zoom End

//popup window
function popupWindow(URL,width,height,left,top)
{
  if (typeof(width)=="undefined"||typeof(height)=="undefined"||width==""||height=="")
  {
  	width="500"
	height="300"
  }  
  if (typeof(left)=="undefined"||typeof(top)=="undefined"||left==""||top=="")
  {
  	left=screen.width/5
	top=screen.height/9
  }
  var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
  var msgWindow = window.open(URL,"", styleStr); 

}

