﻿var fb_domain_name = "maticsoft.com";
var fb_ajax_api_url ="http://www.maticsoft.com/feedback.aspx";
var fb_title_text = "动软反馈";
var fb_validate_text = ["请输入一个有效的邮箱地址","请选择反馈的类型","反馈的内容不得少于 3 个字符"];
var fb_div_html ='<div id="SNbox_title" class="SNbox_head_left"><div class="SNbox_head_right"><div class="SNbox_head" id="SNbox_comment"></div></div></div><div class="SNbox_close" onmousemove="this.style.backgroundImage=\'url(SNbox/aero-close-over.gif)\'" onmouseout="this.style.backgroundImage=\'url(SNbox/aero-close.gif)\'" onclick="box_remove();"></div><div id="SNbox_bg_left"><div id="SNbox_bg_right"><div id="SNbox_bg_inner"></div></div></div><div class="SNbox_content" id="SNbox_content"><div id="feedback_box"><ul id="main_ul"><li><span>您的电子邮件地址:</span><input id="email_txt" type="text" onblur="CheckEmail()"/></li><li><span>反馈类型:</span><select  id="emailtype_sl" onblur="CheckType()" onchange="checkv();"><option value="2008">--- 请选择 ---</option><option value="0">技术支持和使用帮助</option><option value="1">商务合作</option><option value="2">开发相关问题</option></select>&nbsp;<select id="version_sl"><option value="1">1.X版本</option><option value="2">2.0版本</option></select></li><li><span>内容:</span><textarea id="text_content" rows="10" cols="1" onblur="CheckLength(this.value)"></textarea></li><li><input id="submit_btn" type="button" class="snbutton" value="提交反馈" onclick="SendFeed();return false;"/></li>  </ul><div id="err"></div><div id="succeed_div">发送成功. 感谢您的反馈.<input type="button" class="button" onclick="box_remove();" value="关闭窗口" /></div></div></div><div id="close_div"><input class="snbutton" type="button" value="确定关闭" onclick="box_remove();" /></div>';
var fb_sending_text = "正在发送,请稍候...";
var fb_sending_err_text = "发送失败, 请重试.";
function $id(){var objs;if(arguments.length == 1){objs = document.getElementById(arguments[0]);if(!objs) objs = null;}else{objs = [];for(var i=0; i<arguments.length; i++){var obj = document.getElementById(arguments[i]);if(obj) objs.push(obj);}if(objs.length < 1) objs = null;}return objs;}
function $event(action, type, func, obj){if(!obj) obj = window;if(!type || !func) return;if(action == "add"){if(window.attachEvent){obj.attachEvent("on" + type, func);}else{obj.addEventListener(type, func, false);}}else{if(window.detachEvent){obj.detachEvent("on" + type, func);}else{obj.removeEventListener(type, func,false);}}}
function new_req() {if (window.XMLHttpRequest) return new XMLHttpRequest;else if (window.ActiveXObject) {var req;try { req = new ActiveXObject("Msxml2.XMLHTTP"); }catch (e) { try { req = new ActiveXObject("Microsoft.XMLHTTP"); }catch (e) { return null; }}return req;} else return null;}
function post(url, args, fn,sync) {if (typeof(fn) != 'function') return post2(url, args, fn);var req = new_req();req.open('POST', url,!sync);req.setRequestHeader("Method", "POST " + url + " HTTP/1.1");req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");req.onreadystatechange = function() { 
if (req.readyState == 4){
var s;try {s = req.status;}catch (ex) {
fns.error(ex.description || ex);}
if (s == 200)
fn(req);}
}
req.send(args);}

function tb_show(box_title,box_width,box_height,box_id){box_title=fb_title_text;box_id='feedback_box';box_width='606';box_height='420';if (typeof document.body.style.maxHeight === "undefined") {document.body.style.cssText = "height:100%;width:100%;overflow:hidden";if (document.getElementById("SNbox_HideSelect") === null) {var ifr = document.createElement("iframe");ifr.setAttribute("id","SNbox_HideSelect");document.body.appendChild(ifr);$id('SNbox_HideSelect').style.display = 'block';}else return;}var ol = $id('SNbox_overlay');$event('add','click',box_remove,ol);box_position(box_width,box_height);$id('SNbox_comment').innerHTML = box_title;$id('SNbox_overlay').style.display = 'block';$id('SNbox').style.display = 'block';var SNbox_content = $id('SNbox_content');for (var i=0 ;i< SNbox_content.childNodes.length; i++){var c =SNbox_content.childNodes[i];if (c.id != undefined)c.style.display = 'none';}$id(box_id).style.display = 'block';}function box_remove(){try{var ol = $id('SNbox_overlay');$event('remove','click',box_remove,ol);$id('SNbox').style.display = 'none';$id('SNbox_overlay').style.display = 'none';if (typeof document.body.style.maxHeight == "undefined") {var ifr = $id('SNbox_HideSelect');document.body.removeChild(ifr);document.body.style.cssText = "height:auto;width:auto;overflow:hidden";} return false;}catch(ex){}}function box_position(box_width,box_height) {w = document.body.clientWidth;b = $id('SNbox').style;b.marginLeft = '-' + parseInt((box_width / 2),10) +'px';b.marginTop = '-' + parseInt((box_height / 2),10) +'px';b.width = box_width +'px';b.height = (box_height+18) +'px';if (typeof document.body.style.maxHeight == "undefined") {b.position = 'absolute';}else{b.position = 'fixed';}b.zIndex = '1000';b.top = '280px';b.left = (w/2)+'px';$id('SNbox_bg_inner').style.height = $id('SNbox_bg_right').style.height = $id('SNbox_bg_left').style.height =(box_height -9) +'px';        $id('SNbox_bg_inner').style.width = (box_width -6) +'px';$id('SNbox_content').style.width = (box_width -12) +'px';$id('SNbox_content').style.height = (box_height -20) +'px';}
window.onload= function(){
var snbox = document.createElement("div");
snbox.setAttribute('id','SNbox');
snbox.innerHTML = fb_div_html;
var ol = document.createElement("div");
ol.setAttribute('id','SNbox_overlay');
document.body.appendChild(snbox);
document.body.appendChild(ol);
}
function IsEmail(e)
{
return /(\S)+[@]{1}(\S)+[.]{1}(\w)+/.test(e);
}
function CheckEmail()
{
   if(IsEmail($id("email_txt").value))
    {
    $id("err").innerHTML = "&nbsp;";
    $id("err").style.display = 'none';
    return true;
    }
   else
    {
   $id('err').innerHTML = fb_validate_text[0];
   $id("err").style.display = 'block';
    return false;
    }
}
function checkv()
{	$id('version_sl').style.display=(($id('emailtype_sl').value == 0)?'block':'none');  
}
function CheckType()
{
    if($id("emailtype_sl").value ==  2008)
    {
         $id('err').innerHTML = fb_validate_text[1];
   $id("err").style.display = 'block';
        return false;
    }
   else
   {
       $id("err").innerHTML = "&nbsp;";
    $id("err").style.display = 'none';
        return true;
   }

}
function CheckLength()
{
  if($id("text_content").value.length <3)
  {
     $id('err').innerHTML = fb_validate_text[2];
   $id("err").style.display = 'block';
    return false;
  }
  else{
  $id("err").innerHTML = "&nbsp;";
    $id("err").style.display = 'none';
  return true;
  }
}
function SendFeed(){

　 if(!CheckEmail())
       return;

　  if(!CheckType())
       return;

   if(!CheckLength())
       return;
    function rend(xml)
    {
    
	if(xml.responseText=="OK")
	{
        $id("main_ul").style.display='none';
	    $id("err").style.display='none';
        $id("succeed_div").style.display='block';
	}
    };
    var t = $id('emailtype_sl').value
    if (t == 0)
          t = ($id('version_sl').value==1)?5:6;
   
    post(fb_ajax_api_url,"name="+fb_domain_name+"&email="+$id('email_txt').value+"&emailtype="+t+"&content="+$id('text_content').value,rend); 
}
