﻿//function
function ge(z){return document.getElementById(z)}
function gE(z,y){return z.getElementsByTagName(y)}
function ce(z){return document.createElement(z)}
function de(z){z.parentNode.removeChild(z)}
function ct(z){return document.createTextNode(z)}
function rf(){return false}
function tb(){this.blur()}
function ac(z){var a=0,b=0;while(z){a+=z.offsetLeft;b+=z.offsetTop;z=z.offsetParent} return [a,b]}
function gp(o,z){o=o.parentNode;while(o.nodeName!=z){o=o.parentNode;} return o;}

function getEvent(){     //同时兼容ie和ff的写法　　取得操作对像
	 if(document.all)    return window.event;        
	 func=getEvent.caller;            
	 while(func!=null){    
		 var arg0=func.arguments[0];
		 if(arg0){
			 if((arg0.constructor==Event || arg0.constructor ==MouseEvent)
				 || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){    
				 return arg0;
			 }
		 }
		 func=func.caller;
	 }
	 return null;
}

var Get={
windowSize:function()
{
	var width = 0, height = 0;
	if(typeof window.innerWidth == 'number') //Non-IE
	{
		width = window.innerWidth;
		height = window.innerHeight;
		
	}
	else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
  	{
		//IE 6+ in 'standards compliant mode'
		width = document.documentElement.clientWidth;
		height = document.documentElement.clientHeight;
	}
 	else if(document.body && (document.body.clientWidth || document.body.clientHeight))
	{
		//IE 4 compatible
		width = document.body.clientWidth;
		height = document.body.clientHeight;
	}
	return [width, height];
}
,
scroll:function()
{
	var x = 0, y = 0;
	if(typeof(window.pageYOffset) == 'number')
	{
		//Netscape compliant
		x = window.pageXOffset;
		y = window.pageYOffset;
	}
	else if(document.body && (document.body.scrollLeft || document.body.scrollTop))
	{
		//DOM compliant
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}
	else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop))
	{
		//IE6 standards compliant mode
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	}
	return [x, y];
}
}



//Index商品说明显示
var oImage = new Image(); 
oImage.src = "../images/index_img/layout_bg.gif"; 

var shopData = new Array();
shopData[0] = "<p class='cGreen'>显示地图的图片显示地图的图片显示地图的图片</p><br>";
shopData[1] = "<p class='cGreen'>显示地图的图片显示地图的图片显示地图的图片</p><br>";
shopData[2] = "<p class='cGreen'>显示地图的图片显示地图的图片显示地图的图片</p><br>";
shopData[3] = "<p class='cGreen'>显示地图的图片显示地图的图片显示地图的图片</p><br>";
function IndexShop(MapValue, HrefValue){
	var _evt=getEvent(),
	_e=_evt.srcElement || _evt.target;
	TP.show(_e,"<p><p class='cGreen'><a target='_blank' href='" + HrefValue + "' ><img src='../images/"+MapValue+"'/></a></p>",0);
}
//层提示显示
TP = {
	create: function(htmltext){
		var img = new Image();
		img.src = "../images/layout_bg.gif";
		
		var d = ce('div'), t = ce('table'), tb = ce('tbody'), tr1 = ce('tr'), tr2 = ce('tr'), td = ce('td'), th1 = ce('th'), th2 = ce('th'), th3 = ce('th');
		
		d.className = 'interface';
		th1.style.backgroundPosition = 'top right';
		th2.style.backgroundPosition = 'bottom left';
		th3.style.backgroundPosition = 'bottom right';
		if(htmltext) td.innerHTML = htmltext;
		td.id = "tpText";
		tr1.appendChild(td);
		tr1.appendChild(th1);
		tb.appendChild(tr1);
		tr2.appendChild(th2);
		tr2.appendChild(th3);
		tb.appendChild(tr2);
		t.appendChild(tb);
		d.appendChild(t);
		document.body.appendChild(d);
		return d;
	},
	show: function(_this,htmltext,mode){    		//mode:定位类型  0:固定  1:移动
		var _;
		if(!TP.tp){
			_ = TP.create();
			
			TP.tp	=_;
			TP.table = gE(_, 'table')[0];
			TP.td    = gE(_, 'td')[0];
		}
		_ = TP.tp;
		_.style.width = "600px";
		TP.table.style.width = "auto";
		_.style.left = _.style.top = "-2000px";
		
		TP.td.innerHTML = htmltext;		
		TP.fix(_,0);
		if(mode){
			TP.move(_this, _);
		}else{
			var c = ac(_this),
				left = c[0], top = c[1];
			TP.afreshPos(_,left,top,_this.offsetWidth,_this.offsetHeight);
//			_this.onmouseout = TP.hide;
		}
	},
	hide: function(){
		TP.tp.style.visibility = "hidden";
		TP.tp.style.left = TP.tp.style.top = "-2000px";
	},
	fix: function(tp , visible){
		var w;
		if( TP.table.offsetWidth < 72 ){			
			w = Math.max ( TP.table.offsetWidth , 72 );	
		}else{
			w = Math.min(TP.table.offsetWidth , 72);
		}	
		tp.style.width = w + 20 + "px";
		TP.table.style.width = "100%";
		if(visible)
			TP.tp.style.visibility = "visible";
			
	},
	move: function(_this,tp){
		var d=document, SL=Get.scroll(), l, t;
		tp.style.visibility = "visible";
		if(tp.setCapture)
			tp.setCapture();
		else if(window.captureEvents)
			window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
		var evt=getEvent();
		if(document.all){
			l = SL[0] + evt.clientX;
			t = SL[1] + evt.clientY;
		}
		else if(window.captureEvents){
			l = evt.pageX;
			t = evt.pageY;
		}
		TP.afreshPos(tp,l,t,12,12);
		d.onmousemove = function(){
			var evt=getEvent();
    		var _e=evt.srcElement || evt.target;
			if(_e == _this){
				if(document.all){
					l = SL[0] + evt.clientX;
					t = SL[1] + evt.clientY;
				}
				else if(window.captureEvents){
					l = evt.pageX;
					t = evt.pageY;
				}
				TP.afreshPos(tp,l,t,12,12);
			}else{
				if(document.all)
					tp.releaseCapture();
				else if(window.captureEvents)
					window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);
				d.onmousemove = null; 
				TP.hide();
			}
		} // End Document.move
	},
	afreshPos: function(tp,left,top,dw,dh){
		var minx = 0 , miny = 0,
			tow = tp.offsetWidth, toh = tp.offsetHeight,
			WS = Get.windowSize(),
			SL = Get.scroll(),
			bcw = WS[0] , bch = WS[1],
			bsl = SL[0] , bst = SL[1];
			
		if(left + dw + tow > bcw)
			left = Math.max(left - tow -5, minx);
		else
			left += dw;

		if(left < minx)
			left = minx;
		else if(left + tow > bsl + bcw)
			left = bsl + bcw - tow;	
		
		if(top + toh + dh > bst + bch)
			top -= toh + dh ;
		else
			top += dh;
		
		if(top < miny)
			top = miny;
		else if(top < bst)
			top = bst + miny;
			
		
		tp.style.left = left + "px";
		tp.style.top = top + "px";
		tp.style.visibility = "visible";
	}
}
