//在这里处理OnClick的事件

var g_OldTextDecoration;
var g_OldColor;
var g_Oldbgcolor;
var g_OldBorderStyle;
var g_OldBorderWidth;
var g_OldBorderColor;
var g_OldSrc;

function smodelOnClick(obj)
{
	var win,urlLink,urlopen;
	
	var sFeatures;
	sFeatures = obj.winfeature;

	var gmdcid;
	gmdcid = obj.gmdcid;
	if(obj && gmdcid)
	{
		if( gmdcid.indexOf("ecbtn")!=-1 && obj.btnCGI)
		{
			urlopen = obj.btnOpen;
			var proID,proName,proPrice,proTotal;
			
			proID = obj.proID ? obj.proID : "";
			proName = obj.proName ? obj.proName : "";
			proPrice = obj.proPrice ? obj.proPrice : "";
			proTotal = obj.proTotal ? obj.proTotal : "9999";
			if(proTotal==0 || proTotal == "")
			{	
				alert("The product is Out-of-Stock,please select others.");
				return;
			}
			
			urlLink = obj.btnCGI+ "?param1="+proID + "&param2="+ proName + "&param3=" + proPrice ;
			if(urlopen && ((urlopen=="_blank") ))
			{
				var winName;
				winName = obj.gmdcWinName;
				
				if(winName)
				{	if(sFeatures)	
						window.open(urlLink,winName,sFeatures);
					else
						window.open(urlLink,winName);}
				else
				{if(sFeatures)	
						window.open(urlLink,"",sFeatures);
					else
						window.open(urlLink);}
			}
			else
				window.location.href=urlLink;	
		}
		else	
		{
			urlopen = obj.urlopen;
			urlLink = obj.url
			
			if(urlLink) 
			{
				
				if(urlopen && ((urlopen=="_blank") || (urlopen=="yes")))
					if(sFeatures)	
						window.open(urlLink,"",sFeatures);
					else
						window.open(urlLink);
				else
				if(urlopen && urlopen=="top")
					window.top.location.href=urlLink;
				else
				if(urlopen && urlopen=="parent" && window.parent)
				{
					window.parent.location.href=urlLink;
				}
				else
					window.location.href=urlLink;	
			}
		}
	}
}

function smodelOnMouseOver(obj)
{
	if(obj && obj.url)
	{
		g_OldColor = obj.style.color;
		g_Oldbgcolor = obj.style.backgroundColor;
		if(obj.hovercursor)
			obj.style.cursor = obj.hovercursor;
		else
			obj.style.cursor = "hand"
		g_OldTextDecoration = obj.style.textDecoration;

		if(obj.hoverunderline)
			obj.style.textDecoration = obj.hoverunderline;
		else
			obj.style.textDecoration = "underline"	
		obj.style.color	= obj.hovercolor;
		obj.style.backgroundColor = obj.hoverbgcolor;

		if(obj.gmdcid.indexOf("image_")>0)
		{
			g_OldBorderStyle = obj.style.borderStyle;
			g_OldBorderWidth = obj.style.borderWidth;
			g_OldBorderColor = obj.style.borderColor;
			g_OldSrc		 = obj.src;
			if(obj.hoverborderstyle)
				obj.style.borderStyle = obj.hoverborderstyle;

			if(obj.hoverborderwidth)
				obj.style.borderWidth = obj.hoverborderwidth;

			if(obj.hovercolor)
				obj.style.borderColor = obj.hovercolor;
			if(obj.hoversrc)
				obj.src = obj.hoversrc;
		}

	}
}

function smodelOnMouseOut(obj)
{
	if(obj && obj.url)
	{
		if(g_OldTextDecoration)
			obj.style.textDecoration = g_OldTextDecoration
		else
			obj.style.textDecoration = "none"
		if(g_OldColor)
			obj.style.color = g_OldColor;
		else
			obj.style.color = "";
		
		if(g_Oldbgcolor)
			obj.style.backgroundColor = g_Oldbgcolor;
		else
			obj.style.backgroundColor = "";

		if(obj.gmdcid.indexOf("image_")>0)
		{
			obj.style.borderStyle = g_OldBorderStyle;
			obj.style.borderWidth = g_OldBorderWidth;
			obj.style.borderColor = g_OldBorderColor;
			obj.src				  = g_OldSrc;
		}
	}
}



//对齐用
function recalcPos()
{
	var DEF_WIDTH = 780;
	if( document.body.gdc_content_width!=null 
		&& document.body.gdc_content_width!=0)
	{
		DEF_WIDTH = document.body.gdc_content_width;
	}	
	if( document.body.gdc_dc_align=="left" )
	{
		if( document.all.gmdc_main_div != null )
		{
			document.all.gmdc_main_div.style.pixelLeft = 0;
			document.body.style.backgroundPosition = "0 0";
		}	
	}
	else if( document.body.gdc_dc_align=="right" )
	{
		var offsetLeft = (document.body.clientWidth-DEF_WIDTH);
		if( document.all.gmdc_main_div != null )
		{
			if( offsetLeft > 0 )
			{
				document.all.gmdc_main_div.style.pixelLeft = offsetLeft;
				document.body.style.backgroundPositionX = offsetLeft;
			}
			else
			{
				document.all.gmdc_main_div.style.pixelLeft = 0;
				//document.body.style.backgroundPosition = 0;
				document.body.style.backgroundPosition = "0 0";
			}
		}	
	}
	else
	{
		var offsetLeft = (document.body.clientWidth-DEF_WIDTH)/2;
		if( document.all.gmdc_main_div != null )
		{
			if( offsetLeft > 0 )
			{
				document.all.gmdc_main_div.style.pixelLeft = offsetLeft;
				document.body.style.backgroundPositionX = offsetLeft;
			}
			else
			{
				document.all.gmdc_main_div.style.pixelLeft = 0;
				//document.body.style.backgroundPositionX = 0;
				//document.body.style.backgroundPositionY = 0;
				document.body.style.backgroundPosition = "0 0";
			}
		}	
	}
}
//recalcPos();
window.onresize=recalcPos;

