// JavaScript Document

function videoHeader(){
mmoHeader()
}
function videoFooter(){
mmoFooter()
}
//bug report
function win_open_bug(){
	window.open("http://answer.mmosite.com/report/bug2.shtml");
}
/* 显示积分信息  */
function myscore(){
document.getElementById("popLayer").style.display = ""
}
function myscorehide(){
document.getElementById("popLayer").style.display = "none"
}



/*
fun.js
*/
var accuser = GetCookie('mmositeask_user');

function getCookieVal(offset) {
	var endstr=document.cookie.indexOf(";",offset);
	if( endstr==-1 )
		endstr=document.cookie.length;
	return document.cookie.substring(offset,endstr);
}


function setCookie(name, value, expires, path) {
	var str = name + "=" + escape(value);
	if (expires) {
		if (expires == 'never') 
			expires = 100*365*24*60;
		var exp=new Date(); 
		exp.setTime(exp.getTime() + expires*60);
		str += "; expires="+exp.toGMTString();
	}
	if (path) {
		str += "; path=" + path;
	}
	str += "; domain=answer.17173.com";
	document.cookie = str;
} 


function GetCookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	var j;
	while( i<clen ) {
		j = i + alen;
		if( document.cookie.substring(i,j)==arg )
			return getCookieVal(j);
		i = document.cookie.indexOf(" ",i)+1;
		if(i==0)
			break;
	}
	return null;
}


function isLogin()
{
	if(accuser !=null )
		return true;
	else
		return false;
}


//表单在指定大小窗口打开
function newwin(obj,winname){ 
window.open("",winname,"width=400,height=300") 
obj.target=winname; 
} 
function oepnSWin(theURL,width,height)
{
	if(theURL=="")
		return false;
		
	var wHeight = height;
	var wWidth = width;
	var wTop  = (screen.height - wHeight) / 2 ;
	var wLeft = (screen.width  - wWidth) / 2 ;
	
	var wOptions = "toolbar=no" ;
	wOptions += ",width=" + wWidth ; 
	wOptions += ",height=" + wHeight ;
	wOptions += ",resizable=no" ;
	wOptions += ",scrollbars=no" ;
	wOptions += ",left=" + wLeft ;
	wOptions += ",top=" + wTop ;
	window.open(theURL,'_blank',wOptions);
}


function ShowDialog(url)
{
	
	var theURL=url;
	
	
	var wWidth = 551;
	var wHeight = 337;
	var wTop  = (screen.height - wHeight) / 2 ;
	var wLeft = (screen.width  - wWidth) / 2 ;
	
	var wOptions = "toolbar=no" ;
	wOptions += ",width=" + wWidth ; 
	wOptions += ",height=" + wHeight ;
	wOptions += ",resizable=no" ;
	wOptions += ",scrollbars=no" ;
	wOptions += ",left=" + wLeft ;
	wOptions += ",top=" + wTop ;
	 window.open(theURL,'_blank',wOptions);
}	
function ShowDialogW(url,width,height)
{
	
	var theURL=url;
	
	
	var wWidth = width;
	var wHeight = height;
	var wTop  = (screen.height - wHeight) / 2 ;
	var wLeft = (screen.width  - wWidth) / 2 ;
	
	var wOptions = "toolbar=no" ;
	wOptions += ",width=" + wWidth ; 
	wOptions += ",height=" + wHeight ;
	wOptions += ",resizable=no" ;
	wOptions += ",scrollbars=no" ;
	wOptions += ",left=" + wLeft ;
	wOptions += ",top=" + wTop ;
	 window.open(theURL,'_blank',wOptions);
}


function memLogin(obj,backurl)
{
	location.href="/member/mem_login.php?backUrl="+backurl+"&flag="+obj;
}
function ShowLogin(obj,backurl)
{
	
	var wWidth = 600;
	var wHeight = 300;
	var wTop  = (screen.height - wHeight) / 2 ;
	var wLeft = (screen.width  - wWidth) / 2 ;
	
	var wOptions = "toolbar=no" ;
	wOptions += ",width=" + wWidth ; 
	wOptions += ",height=" + wHeight ;
	wOptions += ",resizable=no" ;
	wOptions += ",scrollbars=no" ;
	wOptions += ",left=" + wLeft ;
	wOptions += ",top=" + wTop ;
	
 	//window.open('/member/getin.php?backUrl='+backurl+'&flag='+obj,'_blank',wOptions);
	window.open('/member/getin.php?backUrl='+backurl+'&flag='+obj,'_blank');
	 
}
function getMonthTitle(num)
{
	var arr = new Array();
	arr = Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

	for(i=0;i<arr.length;i++)
	{
		if(num==i)
		{
			str = arr[i];
			break;
		}	
	}
	
	return str;
}

/**
	回答问题ajax
*/
function makeAnswerRequest(url,parameter)
{
	
	http_request = false;
	
	//支持XMlHttpRequest类的浏览器，如mozilla
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
		
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

		

	if (!http_request) {
            alert('对不起，浏览器版本须5.5之上，可以看到类别!');
            return false;
        }
 
        http_request.open('POST', url, true);
        http_request.onreadystatechange =setAnswerInfo;
        http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        http_request.send(parameter);
		
        //http_request.send(null);

}



/**
*发表问题ajax
*/
function makeAskRequest(url,parameter)
{
	
	http_request = false;
	
	//支持XMlHttpRequest类的浏览器，如mozilla
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
		
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

		

	if (!http_request) {
            alert('对不起，浏览器版本须5.5之上，可以看到类别!');
            return false;
        }
 
        http_request.open('POST', url, true);
        http_request.onreadystatechange =setAskInfo;
        http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        http_request.send(parameter);
		
        //http_request.send(null);

}
/**
登陆判断
*/
function makeLoginRequest(url)
{
	
	http_request = false;
	
	//支持XMlHttpRequest类的浏览器，如mozilla
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
		
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

		

	if (!http_request) {
            alert('对不起，浏览器版本须5.5之上，可以看到类别!');
            return false;
        }
 		http_request.open('POST', url, true);
		http_request.onreadystatechange =setLoginInfo;
        http_request.send(null);

}

/**
退出判断
*/
function makeExitRequest(url)
{
	
	http_request = false;
	
	//支持XMlHttpRequest类的浏览器，如mozilla
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
		
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

		

	if (!http_request) {
            alert('对不起，浏览器版本须5.5之上，可以看到类别!');
            return false;
        }
 		http_request.open('POST', url, true);
		http_request.onreadystatechange =setExitInfo;
        http_request.send(null);

}

/**
	点击计算
*/
function makeHitsRequest(url)
{
	
	http_request = false;
	
	//支持XMlHttpRequest类的浏览器，如mozilla
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
		
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

		

	if (!http_request) {
            alert('对不起，浏览器版本须5.5之上，可以看到类别!');
            return false;
        }
 		http_request.open('POST', url, true);
		http_request.onreadystatechange =setHitsInfo;
        http_request.send(null);

}
/*
得到用户积分
*/
function makeUserScoreRequest(url)
{
	
	http_request = false;
	
	
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
		
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

		

	if (!http_request) {
            alert('对不起，浏览器版本须5.5之上，可以看到类别!');
            return false;
        }
 		http_request.open('POST', url, true);
		http_request.onreadystatechange =setUserScoreInfo;
        http_request.send(null);

}


/**
针对用户投票（赞成/反对）
*/
function makeVoteRequest(url)
{
	
	http_request = false;
	
	//支持XMlHttpRequest类的浏览器，如mozilla
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
		
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

		

	if (!http_request) {
            alert('对不起，浏览器版本须5.5之上，可以看到类别!');
            return false;
        }
 
        http_request.open('POST', url, true);
		http_request.onreadystatechange =setVoteInfo;
        http_request.send(null);
}
/**
 * jeditor 1.0 fckeidtor loader Author: neil.mao Email: maoxiang@gmail.com
 * 2009-02-06 更新到fckeditor 2.6.4
 */
( function($) {
	var fckeditor_root = "/plus/fckeditor/";
	var fckeditor_js = fckeditor_root + "fckeditor.js";
	
	// 加载fckeditor.js
	document.write('<script type="text/javascript" src="' + fckeditor_js + '"></scr'+'ipt>');

	$.fn.loadEditor = function(type) {
		return this.each( function() {
			try {
				// 如果未定义id，则不加载
				if (undefined == this.id || !this.id.length) return;
				var value = $(this).html();
				$(this).html("Please wait a moment for the initialization....");
				var oFCKeditor = new FCKeditor(this.id);
				oFCKeditor.BasePath = fckeditor_root;
				oFCKeditor.Width = $(this).width();
				oFCKeditor.Height = $(this).height();
				oFCKeditor.Value = value;
				switch (type) {
					case 0: // 标准配置
						oFCKeditor.Config['CustomConfigurationsPath'] = fckeditor_root + 'fckconfig.js';
						oFCKeditor.ToolbarSet = 'Default';
						break;
					case 1: // 最小配置
						oFCKeditor.Config['CustomConfigurationsPath'] = fckeditor_root + 'answer.fckconfig.js';
						oFCKeditor.ToolbarSet = 'answer';
						break;
				}
				$(this).html(oFCKeditor.CreateHtml());
			} catch (e) {
				alert("Error:" + e.message);
			}
		});
	};
	$.fn.getEditorHtml = function() {
		if (this.length > 0) {
			var o = this[0];
			if (undefined == o.id || !o.id.length)
				return;
			var oEditor = FCKeditorAPI.GetInstance(o.id);
			// Get the editor contents in XHTML.
			// "true" means you want it formatted.
			return (oEditor.GetXHTML(true));
		}
		;
		return "";
	};

	$.fn.setEditorHtml = function(html) {
		if (this.length > 0) {
			var o = this[0];
			if (undefined == o.id || !o.id.length)
				return;
			var oEditor = FCKeditorAPI.GetInstance(o.id);
			// Get the editor contents in XHTML.
			// "true" means you want it formatted.
			oEditor.InsertHtml(html);
		}
		;
	};
})(jQuery);