var WebSite = "http://www.chris.com"
var StringLength = WebSite.length;
var alertWidth = 300;
var alertHeight = 180;

//获取页面ID为objString的对象
function $(objString){
	return document.getElementById(objString);
}

function showAlert(alertString,width,height,windowType,returnAction){
	top.createDiv('','100%','100%');
	if (!width){width = alertWidth;}
	if (!height){height = alertHeight;}
	if (parseInt(width) < alertWidth){width = alertWidth;}
	if (parseInt(height) < alertHeight){height = alertHeight;}
	top.createDiv('AlertMsg',width,height,'提示窗口');
	switch (windowType){
		case "alert":
			if (!returnAction){returnAction = '';}
			top.AlertMsg_zone.innerHTML = '<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="1" align="center" style="padding-left:30px;"><img src="images/image_062.gif" /></td><td style="padding-left:20px; padding-right:30px; font-weight:bold; color:930002;">' + alertString + '</td></tr></table></td></tr><tr><td height="40" align="center" valign="top"><input type="button" id="alertSubmit" name="alertSubmit" value="确 定" onClick="' + returnAction + 'top.delDiv(\'AlertMsg\');" tag="WebControl" /></td></tr></table>';
			if (top.controlInit){
				top.controlInit();
				top.$alertSubmit.Focus();
			}
			break;
		case "info":
			if (!returnAction){returnAction = '';}
			top.AlertMsg_zone.innerHTML = '<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="1" align="center" style="padding-left:30px;"><img src="images/image_063.gif" /></td><td style="padding-left:20px; padding-right:30px; font-weight:bold; color:2543a5;">' + alertString + '</td></tr></table></td></tr><tr><td height="40" align="center" valign="top"><input type="button" id="alertSubmit" name="alertSubmit" value="确 定" onClick="' + returnAction + 'top.delDiv(\'AlertMsg\');" tag="WebControl" /></td></tr></table>';
			if (top.controlInit){
				top.controlInit();
				top.$alertSubmit.Focus();
			}
			break;
		case "yesno":
			if (returnAction.search(/\{split\}/i) >= 0){
				top.AlertMsg_zone.innerHTML = '<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="1" align="center" style="padding-left:30px;"><img src="images/image_064.gif" /></td><td style="padding-left:20px; padding-right:30px; font-weight:bold; color:930002;">' + alertString + '</td></tr></table></td></tr><tr><td height="40" align="center" valign="top"><input type="button" id="alertSubmit_yes" name="alertSubmit_yes" value="是" onClick="' + returnAction.split("{split}")[0] + 'top.delDiv(\'AlertMsg\');" tag="WebControl" />&nbsp;&nbsp;<input type="button" id="alertSubmit_no" name="alertSubmit_no" value="否" onClick="' + returnAction.split("{split}")[1] + 'top.delDiv(\'AlertMsg\');" tag="WebControl" /></td></tr></table>';
				if (top.controlInit){
					top.controlInit();
					top.$alertSubmit_no.Focus();
				}
				//alertWindow.innerHTML = '<div style="padding:20px; text-align:center;">' + alertString + '</div><div style="text-align:center; padding:20px;"><input id="buttonClose" name="buttonClose" type="button" value="是" onClick="' + returnAction.split("{split}")[0] + 'top.delDiv(\'AlertMsg\');"><input id="buttonClose" name="buttonClose" type="button" value="否" onClick="' + returnAction.split("{split}")[1] + 'top.delDiv(\'AlertMsg\');"></div>';
			}else{
				top.AlertMsg_zone.innerHTML = '<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="1" align="center" style="padding-left:30px;"><img src="images/image_064.gif" /></td><td style="padding-left:20px; padding-right:30px; font-weight:bold; color:930002;">' + alertString + '</td></tr></table></td></tr><tr><td height="40" align="center" valign="top"><input type="button" id="alertSubmit_yes" name="alertSubmit_yes" value="是" onClick="' + returnAction + 'top.delDiv(\'AlertMsg\');" tag="WebControl" />&nbsp;&nbsp;<input type="button" id="alertSubmit_no" name="alertSubmit_no" value="否" onClick="top.delDiv(\'AlertMsg\');" tag="WebControl" /></td></tr></table>';
				if (top.controlInit){
					top.controlInit();
					top.$alertSubmit_no.Focus();
				}
				//alertWindow.innerHTML = '<div style="padding:20px; text-align:center;">' + alertString + '</div><div style="text-align:center; padding:20px;"><input id="buttonClose" name="buttonClose" type="button" value="是" onClick="' + returnAction + 'top.delDiv(\'AlertMsg\');"><input id="buttonClose" name="buttonClose" type="button" value="否" onClick="top.delDiv(\'AlertMsg\');"></div>';
			}
			break;
		case "confirmcancel":
			if (returnAction.search(/\{split\}/i) >= 0){
				top.AlertMsg_zone.innerHTML = '<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="1" align="center" style="padding-left:30px;"><img src="images/image_064.gif" /></td><td style="padding-left:20px; padding-right:30px; font-weight:bold; color:930002;">' + alertString + '</td></tr></table></td></tr><tr><td height="40" align="center" valign="top"><input type="button" id="alertSubmit_yes" name="alertSubmit_yes" value="确 定" onClick="' + returnAction.split("{split}")[0] + 'top.delDiv(\'AlertMsg\');" tag="WebControl" />&nbsp;&nbsp;<input type="button" id="alertSubmit_no" name="alertSubmit_no" value="取 消" onClick="' + returnAction.split("{split}")[1] + 'top.delDiv(\'AlertMsg\');" tag="WebControl" /></td></tr></table>';
				if (top.controlInit){
					top.controlInit();
					top.$alertSubmit_no.Focus();
				}
			}else{
				if (!returnAction){returnAction = '';}
				top.AlertMsg_zone.innerHTML = '<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="1" align="center" style="padding-left:30px;"><img src="images/image_064.gif" /></td><td style="padding-left:20px; padding-right:30px; font-weight:bold; color:930002;">' + alertString + '</td></tr></table></td></tr><tr><td height="40" align="center" valign="top"><input type="button" id="alertSubmit_yes" name="alertSubmit_yes" value="确 定" onClick="' + returnAction + 'top.delDiv(\'AlertMsg\');" tag="WebControl" />&nbsp;&nbsp;<input type="button" id="alertSubmit_no" name="alertSubmit_no" value="取 消" onClick="top.delDiv(\'AlertMsg\');" tag="WebControl" /></td></tr></table>';
				if (top.controlInit){
					top.controlInit();
					top.$alertSubmit_no.Focus();
				}
			}
			break;
	}
}

function ctlent(objectname){
	if (event.keyCode == 27){
		if (eval('top.' + objectname + '_' + top.divCount)){top.delDiv(objectname);}
	}
}

/*=======================================================
等比缩略图函数.自适应长/宽型.
传进参数
	objZone:显示的标签
	defaultWidth:缩小宽度
	defaultHeight:缩小高度
	src:图片地址
=======================================================*/
var img = null;
function ActionImg(objZone,defaultWidth,defaultHeight,src){
	if(img)img.removeNode(true);
	img = document.createElement("img");
	img.style.position = "absolute";
	img.style.visibility = "hidden";
	img.attachEvent("onreadystatechange",function(){orsc(objZone,defaultWidth,defaultHeight,src);});
	img.attachEvent("onerror",function(){oe(objZone);});
	document.body.insertAdjacentElement("afterBegin",img);
	img.src = src;
}

function oe(objZone){
	objZone.innerHTML = '图片获取失败';
	img.removeNode(true);
}

function orsc(objZone,defaultWidth,defaultHeight,src){
	imgWidth = 0;
	imgHeight = 0;
	if(img.readyState!="complete"){
		objZone.innerHTML = '正在获取图片';
	}else{
		if ((defaultWidth / img.offsetWidth) < (defaultHeight /img.offsetHeight) && img.offsetWidth > defaultWidth){
			imgWidth = defaultWidth;
			imgHeight = parseInt(img.offsetHeight * (defaultWidth / img.offsetWidth));
		}else if ((defaultWidth /img.offsetWidth) > (defaultHeight / img.offsetHeight) && img.offsetHeight > defaultHeight){
			imgHeight = defaultHeight;
			imgWidth = parseInt(img.offsetWidth * (defaultHeight / img.offsetHeight));
		}else if (img.offsetWidth > defaultWidth){
			imgWidth = defaultWidth;
			imgHeight = defaultHeight;
		}else{
			imgWidth = img.offsetWidth;
			imgHeight = img.offsetHeight;
		}
		objZone.innerHTML = '<img width="' + imgWidth + '" height="' + imgHeight + '" src="' + src + '" border="0">';
		img.removeNode(true);
	}
}
/*=======================================================
等比缩略图函数.结束
=======================================================*/
