﻿//在这里处理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)
	{
                urlopen = obj.urlopen;
                urlLink = obj.url
                if(urlLink)
                {
                        if(urlopen && (urlopen=="_custom"))
						{
                                if(sFeatures)
                                        window.open(urlLink,"",sFeatures);
                                else
                                        window.open(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.hoverimgsrc)
				obj.src = obj.hoverimgsrc;
		}

	}
	if(obj && (obj.mailto || obj.formto))
	{
                if (obj.mailto)
                {
                    var url = "http://diy.itpal.cn/page_edit/sendmail.jsp";
//                    var url = "http://localhost:8000/page_edit/sendmail.jsp";
                    url += "?dc_mailto=" + obj.mailto;
                    url += "&dc_mailtitle=" + obj.mailtitle;
                    url += "&dc_mailfrom=" + obj.mailfrom;
                    dc_form.action = url;
                    dc_form.method = "post";
                    dc_form.target = "_blank";
                }
                else
                {
                    dc_form.action = obj.formto;
                    dc_form.method = obj.formtype;
                    dc_form.target = obj.formtag;
                }
/*
		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 inithtml()
{
  recalcPos();
//  alert(document.body.gdc_content_width);
}

//对齐用
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 )
		{
				if ((null != document.body.style.backgroundPositionX)&&('' == document.body.style.backgroundPositionX))
				{
					document.body.style.backgroundPosition = "0 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;
				if ((null != document.body.style.backgroundPositionX)&&(!(('left' == document.body.style.backgroundPositionX)||('center' == document.body.style.backgroundPositionX)||('right' == document.body.style.backgroundPositionX))))
				{
					document.body.style.backgroundPositionX = offsetLeft;
				}
			}
			else
			{
				if ((null != document.body.style.backgroundPositionX)&&(!(('left' == document.body.style.backgroundPositionX)||('center' == document.body.style.backgroundPositionX)||('right' == document.body.style.backgroundPositionX))))
				{
					document.body.style.backgroundPositionX = 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 )
		{
//                        alert(document.body.style.backgroundPositionX);
			if( offsetLeft > 0 )
			{
				document.all.gmdc_main_div.style.pixelLeft = offsetLeft;
				if ((null != document.body.style.backgroundPositionX)&&(!(('left' == document.body.style.backgroundPositionX)||('center' == document.body.style.backgroundPositionX)||('right' == document.body.style.backgroundPositionX))))
				{
					document.body.style.backgroundPositionX = offsetLeft;
				}
			}
			else
			{
				document.all.gmdc_main_div.style.pixelLeft = 0;
				if ((null != document.body.style.backgroundPositionX)&&(!(('left' == document.body.style.backgroundPositionX)||('center' == document.body.style.backgroundPositionX)||('right' == document.body.style.backgroundPositionX))))
				{
					document.body.style.backgroundPositionX = 0;
				}
				//document.body.style.backgroundPositionX = 0;
				//document.body.style.backgroundPositionY = 0;
//				document.body.style.backgroundPosition = "0 0";
			}
		}
	}

	var DEF_HEIGHT = 0;
	if( document.body.gdc_content_height!=null
		&& document.body.gdc_content_height!=0)
	{
		DEF_HEIGHT = document.body.gdc_content_height;
	}
        if (DEF_HEIGHT == 0){
                return;
        }
	if( document.body.gdc_dc_valign=="middle" )
	{
		var offsetTop = (document.body.clientHeight-DEF_HEIGHT)/2;
		if( document.all.gmdc_main_div != null )
		{
			if( offsetTop > 0 )
			{
				document.all.gmdc_main_div.style.pixelTop = offsetTop;
				document.body.style.backgroundPositionY = offsetTop;
			}
			else
			{
				document.all.gmdc_main_div.style.pixelTop = 0;
				//document.body.style.backgroundPositionX = 0;
				//document.body.style.backgroundPositionY = 0;
				document.body.style.backgroundPosition = "0 0";
			}
		}
	}
	else if( document.body.gdc_dc_valign=="bottom" )
	{
		var offsetTop = (document.body.clientHeight-DEF_HEIGHT);
		if( document.all.gmdc_main_div != null )
		{
			if( offsetTop > 0 )
			{
				document.all.gmdc_main_div.style.pixelTop = offsetTop;
				document.body.style.backgroundPositionY = offsetTop;
			}
			else
			{
				document.all.gmdc_main_div.style.pixelTop = 0;
				//document.body.style.backgroundPosition = 0;
				document.body.style.backgroundPosition = "0 0";
			}
		}
	}
	else
	{
		if( document.all.gmdc_main_div != null )
		{
			document.all.gmdc_main_div.style.pixelTop = 0;
			document.body.style.backgroundPosition = "0 0";
		}
	}

}
//recalcPos();
window.onresize=recalcPos;
//var thispageurl = window.location.href;
//if (thispageurl.indexOf("edit_preview.jsp") != -1 )
//{
//  window.onload=inithtml;
//}

