
var t_DiglogX,t_DiglogY,t_DiglogW,t_DiglogH;

function gid(id) {
return document.getElementById?document.getElementById(id):null;
}

function gname(name) {
return document.getElementsByTagName?document.getElementsByTagName(name):new Array()
}

function Browser() {
var ua, s, i;
this.isIE = false;
this.isNS = false;
this.isOP = false;
this.isSF = false;
ua = navigator.userAgent.toLowerCase();
s = "opera";
if ((i = ua.indexOf(s)) >= 0) {
this.isOP = true;return;
}
s = "msie";
if ((i = ua.indexOf(s)) >= 0) {
this.isIE = true;return;
}
s = "netscape6/";
if ((i = ua.indexOf(s)) >= 0) {
this.isNS = true;return;
}
s = "gecko";
if ((i = ua.indexOf(s)) >= 0) {
this.isNS = true;return;
}
s = "safari";
if ((i = ua.indexOf(s)) >= 0) {
this.isSF = true;return;
}
}

function DialogLoc() {
var dde = document.documentElement;
if (window.innerWidth) {
var ww = window.innerWidth;
var wh = window.innerHeight;
var bgX = window.pageXOffset;
var bgY = window.pageYOffset;
} else {
var ww = dde.offsetWidth;
var wh = dde.offsetHeight;
var bgX = dde.scrollLeft;
var bgY = dde.scrollTop;
}
t_DiglogX = (bgX + ((ww - t_DiglogW)/2));
t_DiglogY = (bgY + ((wh - t_DiglogH)/2));
}

function DialogShow(showdata,ow,oh,w,h) {
var objDialog = document.getElementById("DialogMove");
if (!objDialog) objDialog = document.createElement("div");
t_DiglogW = ow;
t_DiglogH = oh;
DialogLoc();
objDialog.id = "DialogMove";
var oS = objDialog.style;
oS.display = "block";
oS.top = t_DiglogY + "px";
oS.left = t_DiglogX + "px";
oS.margin = "0px";
oS.padding = "0px";
oS.width = w + "px";
oS.height = h + "px";
oS.position = "absolute";
oS.zIndex = "5";
oS.background = "#FFF";
oS.border = "solid #000 3px";
objDialog.innerHTML = showdata;
document.body.appendChild(objDialog);
}

function DialogHide() {
ScreenClean();
var objDialog = document.getElementById("DialogMove");
if (objDialog) objDialog.style.display = "none";
}

function ScreenConvert() {
var browser = new Browser();
var objScreen = gid("ScreenOver");
if (!objScreen) var objScreen = document.createElement("div");
var oS = objScreen.style;
objScreen.id = "ScreenOver";
oS.display = "block";
oS.top = oS.left = oS.margin = oS.padding = "0px";
if (document.body.clientHeight)    {
var wh = document.body.clientHeight + "px";
} else if (window.innerHeight) {
var wh = window.innerHeight + "px";
} else {
var wh = "100%";
}
oS.width = "100%";
oS.height = wh;
oS.position = "absolute";
oS.zIndex = "3";
if ((!browser.isSF) && (!browser.isOP)) {
oS.background = "";
} else {
oS.background = "";
}
oS.filter = "alpha(opacity=40)";
oS.opacity = 40/100;
oS.MozOpacity = 40/100;
document.body.appendChild(objScreen);
//var allselect = gname("select");
//for (var i=0; i<allselect.length; i++) allselect.style.visibility = "hidden";
}

function ScreenClean() {
var objScreen = document.getElementById("ScreenOver");
if (objScreen) objScreen.style.display = "none";
//var allselect = gname("select");
//for (var i=0; i<allselect.length; i++) allselect.style.visibility = "visible";
}

function report(up_down)
{   
   var showData = itr_error.innerHTML ;

   showData = showData.replace(/<INPUT id=tmp_up_down type=hidden name=tmp_up_down>/g,"<input type=hidden id=up_down name=up_down value="+up_down+">") ;
   showData = showData.replace(/tmp_user_name/g,"user_name") ;
   showData = showData.replace(/tmp_tel/g,"tel") ;
   showData = showData.replace(/tmp_email/g,"email") ;
   showData = showData.replace(/tmp_content/g,"content") ;
   showData = showData.replace(/tmp_input_error/g,"input_error") ;
   
   ScreenConvert();DialogShow(showData,400,100,420,320) ;
}

function add_itr_error(source_id, source_type, up_down)
{
	var obj_user_name = gid("user_name") ;
	var obj_up_down = gid("up_down") ;
	var obj_tel = gid("tel") ;
	var obj_email = gid("email") ;
	var obj_content = gid("content") ;
	var obj_input_error = gid("input_error") ;
	
	if (obj_user_name != null && obj_email != null && obj_content != null)
	{
		if ((obj_user_name.value).length < 1 || (obj_user_name.value).length > 50)
		{
			obj_input_error.innerHTML = "<font color='red'>姓名长度应在1-50字之间!</font>" ;
			obj_user_name.focus();
			return false;
		}
		if ((obj_email.value).length < 1 || (obj_email.value).length > 100)
		{
			obj_input_error.innerHTML = "<font color='red'>邮件地址长度应在1-100字之间!</font>";
			obj_email.focus();
			return false;
		}
		else
		{
			var rx = new RegExp(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/);
			var matches = rx.exec(obj_email.value);
			if (matches == null || (obj_email.value) != matches[0])
			{
				obj_input_error.innerHTML = "<font color='red'>邮件地址格式错误,请重新输入!</font>";
				obj_email.focus();
				return false;
			}
		}
		if ((obj_content.value).length < 1 || (obj_content.value).length > 1000)
		{
			obj_input_error.innerHTML = "<font color='red'>内容长度应在1-1000字之间!</font>";
			obj_content.focus();
			return false;
		}
		
		getContentToFunc("itr_error_add.jsp?source_id="+source_id+"&source_type="+source_type+"&up_down="+obj_up_down.value+"&user_name="+obj_user_name.value+"&tel="+obj_tel.value+"&email="+obj_email.value+"&content="+obj_content.value, "null", error_accept_date, "text") ;
	}
	
	return false;
}

function error_accept_date(_str1, _str2)
{	
	if ( _str2 == 4 )
	{
		DialogHide() ;
		alert("您的纠错已保存，谢谢您的支持！") ;
	}
}

//更换星星
var star_power = true ;
var star_score = 0 ;
var star_tig=["还没评","很糟糕","待改进","一般吧","还不错","非常好"];

function change_star(str)
{
	if ( star_power )
	{
		var imgList = document.getElementsByName("img_star") ;
		var imgScore = document.getElementById("img_score") ;
		
		for ( var i = 0 ; i < str ; i++ )
		{
			 imgList[i].src = "../images/star_1.gif" ;   
		}
		
		for ( var i = str ; i < imgList.length ; i++ )
		{
			 imgList[i].src = "../images/star_2.gif" ;   
		}
		
		imgScore.innerHTML = str + "分 " + star_tig[str] ;
		imgScore.style.color = "#AAAAAA" ;
	}
}

function choice_star(str)
{
	var imgScore = document.getElementById("img_score") ;
	
	if ( star_power )
	{
		star_power = false ;
		imgScore.style.color = "#000000" ;
		imgScore.style.fontSize = "14px" ;
		star_score = str ;
	}
	else
	{
		star_power = true ;
		imgScore.style.color = "#AAAAAA" ;
		imgScore.style.fontSize = "14px" ;
		star_score = 0 ;
	}
}

function score_save(id)
{
	if ( !star_power )
	{
		getContentToFunc("star_score_add.jsp?info_id="+id+"&star_score="+star_score, "null", score_accept_date, "text") ;
	}
	else
	{
		alert("请点击星星确定分数再提交！") ;
	}
}

function score_accept_date(_str1, _str2)
{
	var tmp_score = _str1.replace(/(^\s*)|(\s*$)/g,"") ;
	if ( _str2 == 4 )
	{
		
		document.all["lbnum"].innerText = tmp_score ;
		document.all("submit1").disabled = true ;
		alert("您的评分已经保存,谢谢您的支持！") ;
	}
}

