var feedback = function(){};
feedback.prototype.creatWin = function(){
	Mark.showHintDiv();
	var html = "";
	var container = document.createElement("DIV");
	container.id = "feedback";
	html += "<form id='ui_fb' name='ui_fbn'>"
	html += "<div class='fb_top'>"
	html += "<div class='title'>意见反馈</div><div class='btnBar' onClick='Mark.close();'><img src='/control/images/close_btn.gif'/></div>"
	html += "</div>"
	html += "<div class='clear'></div>"
	html += "<div class='fb_left'>"
	html += "<ul><li>页面美观：</li><li>易用程度：</li><li>内容分类：</li><li>反馈意见：</li></ul>"
	html += "</div>"
	html += "<div class='fb_right' id='fb_c'>"
	html += "<ul id='evaluate'>"
	html += "<li id='f_img'><a title='点击投票' onMouseDown='fp_check();'><img onmousedown='f_num(1);' src='/control/images/darkstar.gif'><img onmousedown='f_num(2);' src='/control/images/darkstar.gif'><img onmousedown='f_num(3);' src='/control/images/darkstar.gif'><img onmousedown='f_num(4);' src='/control/images/darkstar.gif'><img onmousedown='f_num(5);' src='/control/images/darkstar.gif'></a><span id='fp_ct' style='color:#ff6600'>&nbsp;(*请点击左边星星,给予评分)</span></li>"
	html += "<input name='fpoint' type='hidden'/>"
	html += "<li id='m_img'><a title='点击投票' onMouseDown='mp_check();'><img onmousedown='m_num(1);' src='/control/images/darkstar.gif'><img onmousedown='m_num(2);' src='/control/images/darkstar.gif'><img onmousedown='m_num(3);' src='/control/images/darkstar.gif'><img onmousedown='m_num(4);' src='/control/images/darkstar.gif'><img onmousedown='m_num(5);' src='/control/images/darkstar.gif'></a><span id='mp_ct' style='color:#ff6600'>&nbsp;(*请点击左边星星,给予评分)</span></li>"
	html += "<input name='mpoint' type='hidden'/>"
	html += "<li id='l_img'><a title='点击投票' onMouseDown='lp_check();'><img onmousedown='l_num(1);' src='/control/images/darkstar.gif'><img onmousedown='l_num(2);' src='/control/images/darkstar.gif'><img onmousedown='l_num(3);' src='/control/images/darkstar.gif'><img onmousedown='l_num(4);' src='/control/images/darkstar.gif'><img onmousedown='l_num(5);' src='/control/images/darkstar.gif'></a><span id='lp_ct' style='color:#ff6600'>&nbsp;(*请点击左边星星,给予评分)</span></li>"
	html += "<input name='lpoint' type='hidden'/>"
	html += "</ul>"
	html += "<textarea id='comment' name='comment'><欢迎您留下宝贵的意见！></textarea>"
	html += "<input name='fb_submit' type='submit' value='提　交' onClick='fb_send()'><input name='fb_reset' type='reset' value='重　置'>"
	html += "</div>"
	html += "<div class='fb_shadowright'><img src='/control/images/fb_shadowright.gif'></div>"
	html += "<div class='clear'></div>"
	html += "<div class='fb_footer'></div>"
	html += "</form>"
	container.innerHTML = html;
	document.body.appendChild(container);
	container.style.top = "100px";
	container.style.left = "50%";
	container.style.marginLeft = "-234px";
	textareaOver();
	evaluate();
	
}
	
function evaluate(){
	var evaluate = document.getElementById("evaluate").getElementsByTagName("li");
	var starA = "/control/images/yellowstar.gif";
	var starB = "/control/images/yellowstar.gif";
	var starC = "/control/images/darkstar.gif";
	for(var i=0;i<evaluate.length;i++){
		var stars = evaluate[i].getElementsByTagName("img");
		for(var j=0;j<stars.length;j++){
			stars[j].setAttribute("index",j+1);
			stars[j].onclick = function(){
				var before = this.previousSibling;
				var behind = this.nextSibling;
				var value = 1;
				this.setAttribute("src",starA);
				while(before){
					before.setAttribute("src",starA);
					before = before.previousSibling;
					//alert(value);
					value++;
				}
				while(behind){
					behind.setAttribute("src",starC);
					behind = behind.nextSibling;
				}
				this.parentNode.setAttribute("value",value);
				this.parentNode.setAttribute("ismarked",true);
			}
			stars[j].onmouseover = function(){
				var before = this.previousSibling;
				var behind = this.nextSibling;
				if(!this.parentNode.getAttribute("ismarked")){
					this.setAttribute("src",starB);
					while(before){
						before.setAttribute("src",starB);
						before = before.previousSibling;
					}
					while(behind){
						behind.setAttribute("src",starC);
						behind = behind.nextSibling;
					}
				}else{
					if(this.getAttribute("index") > (this.parentNode.getAttribute("value"))){
						var self = this;
						var behind = this.nextSibling;
						for(var k = this.getAttribute("index");k > this.parentNode.getAttribute("value");k--){
							self.setAttribute("src",starB);
							self = self.previousSibling;
						}
						while(behind){
							behind.setAttribute("src",starC);
							behind = behind.nextSibling;
						}
					}
				}
			}
			stars[j].onmouseout = function(){
				if(this.parentNode.getAttribute("ismarked")){
					if(this.getAttribute("index") > (this.parentNode.getAttribute("value"))){
						var self = this;
						var behind = this.nextSibling;
						for(var k = this.getAttribute("index");k > this.parentNode.getAttribute("value");k--){
							self.setAttribute("src",starC);
							self = self.previousSibling;
						}
						while(behind){
							behind.setAttribute("src",starC);
							behind = behind.nextSibling;
						}
					}
				}else{
					var before = this.previousSibling;
					var behind = this.nextSibling;
					this.setAttribute("src",starC);
					while(before){
						before.setAttribute("src",starC);
						before = before.previousSibling;
					}
					while(behind){
						behind.setAttribute("src",starC);
						behind = behind.nextSibling;
					}
				}
			}
		}
	}
}

function textareaOver(){
	var comment = document.getElementById("comment");
	comment.onmouseover = function()
	{
		if(this.value == "<欢迎您留下宝贵的意见！>")
		this.select();
	}
}

 var Ajax = function(){
	var ajax = null;
	if(!window.XMLHttpRequest){
		try{
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}else{
		ajax = new XMLHttpRequest();
	}
	return ajax;
 }


function loadData(node){
	var ajax = Ajax();
	ajax.onreadystatechange = function(){
		if(ajax.readyState==4){
			if(ajax.status == 200){
				var xmlObj = ajax.responseXML;
				var items = xmlObj.getElementsByTagName("items");
				document.getElementById("InfoFrame").innerHTML = "";
			}else{
				document.getElementById("InfoFrame").innerHTML = "数据载入出错，请重新尝试……";
			}
		}else{
			document.getElementById("InfoFrame").innerHTML = Navigator.LOADING;
		}
	};
	ajax.open("POST",Navigator.FILEURL,true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	if(isIE){
		ajax.send();
	}else{
		ajax.overrideMimeType("text/xml");
		ajax.send(null);
	}
	
	var pObj = null;
	function divOver(){
		//if(pObj == this)
		//	return;
		this.className = "itemOver";
		pObj = this;
	}
	function divOut(){
		//if(pObj == this)
			//return;
		pObj.className = "item";
	}
	function divClick(url){
		document.location.href= url;
	}
}

//feedback ajax submit by wang

function fb_send(){
	var options = { 
        target:'#output1',   // target element(s) to be updated with server response 
	url:'/servercenter/site_feedback.php',
		type:'post',
		dataType:'html',
        beforeSubmit:uifb_send,  // pre-submit callback 
        success:uifb_rs  // post-submit callback
		//timeout:600 
    };  
    jq_wang('#ui_fb').ajaxForm(options);  
}

function uifb_send(formData, jqForm, options) {
	var queryString = jq_wang.param(formData);
	//alert(queryString);
	if(p_check_l()){
		jq_wang("#fb_c").html("<div style='margin:90px;'><strong>正在提交数据,请稍候!</strong></div>");
		return true; 
	}else{
		return false;
	}
}

function uifb_rs(responseText, statusText)  {
	//alert(responseText);
	if(responseText>0){
		jq_wang("#fb_c").html("<div style='margin:90px;'><strong>您的反馈已提交,谢谢参与!</strong></div>");
	}else{
		jq_wang("#fb_c").html("<div style='margin:90px;'><strong>提交失败!</strong></div>");
	}
}

function f_num(n){
	document.ui_fbn.fpoint.value=n;
}
function m_num(n){
	document.ui_fbn.mpoint.value=n;
}
function l_num(n){
	document.ui_fbn.lpoint.value=n;
}



function fp_check(){
	if(document.ui_fbn.fpoint.value==""){
		jq_wang("#fp_ct").html("&nbsp;(*必选)");
		return false;
	}else{
		jq_wang("#fp_ct").html("");
		return true;
	}
}

function mp_check(){
	if(document.ui_fbn.mpoint.value==""){
		jq_wang("#mp_ct").html("&nbsp;(*必选)");
		return false;
	}else{
		jq_wang("#mp_ct").html("");
		return true;
	}
}


function lp_check(){
	if(document.ui_fbn.lpoint.value==""){
		jq_wang("#lp_ct").html("&nbsp;(*必选)");
		return false;
	}else{
		jq_wang("#lp_ct").html("");
		return true;
	}
}

function pc_check(){
	if(document.ui_fbn.comment.value==""){
		document.ui_fbn.comment.value="(*必填)";
		return false;
	}else{
		return true;
	}
}

function p_check_l(){
	if(fp_check()&&mp_check()&&lp_check()){
		return true;
	}else{
		fp_check();
		mp_check();
		lp_check();
		return false;
	}
}


