﻿/*********************************************
 VALIDA BUSCA
*********************************************/
function validabusca(){
	erro = "";
	if (document.searchform.s.value == "Busca no blog") {
		erro = erro + "Voce deve informar uma palavra/texto para busca.\n";
	}
	if (erro == "") {
		document.searchform.submit();
	} else {	
		alert("Aconteceram os seguintes erros:           \n\n" + erro);	
	}

}

if(Browser == undefined){
	var Browser = {
		isIE: function(){ return (window.ActiveXObject && document.all && navigator.userAgent.toLowerCase().indexOf("msie") > -1  && navigator.userAgent.toLowerCase().indexOf("opera") == -1) ? true : false; }
	}
}

var Flash = function(movie, id, width, height, initParams){

	this.html = "";
	this.attributes = this.params = this.variables = null;
	
	this.variables = new Array();
	this.attributes = {
		"classid": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
		"codebase": "http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab#version=9,0,22,0",
		"type": "application/x-shockwave-flash"
	}
	this.params = { "pluginurl": "http://www.macromedia.com/go/getflashplayer_br" };
	
	if(movie) {
		this.addAttribute("data", movie);
		this.addParameter("movie", movie);
	}
	
	if(id && id != null) this.addAttribute("id", id);
	if(width) this.addAttribute("width", width);
	if(height) this.addAttribute("height", height);
	
	if(initParams != undefined){
		for(var i in initParams){
			this.addParameter(i.toString(), initParams[i]);
		}
	}
	
}
Flash.version = "1.2b";
Flash.getObjectByExceptions = function(obj, excep){
	var tempObj = {};
	for(var i in obj){
		var inclui = true;
		for(var j=0; j<excep.length; j++)
			if(excep[j] == i.toString()) { inclui = false; break; };
		if(inclui) tempObj[i] = obj[i];
	}
	return tempObj;
}
Flash.prototype.addAttribute = function(prop, val){ this.attributes[prop] = val; }
Flash.prototype.addParameter = function(prop, val){ this.params[prop] = val; }
Flash.prototype.addVariable = function(prop, val){ this.variables.push([prop, val]); }
Flash.prototype.getFlashVars = function(){
	var tempString = new Array();
	
	for(var i=0; i<this.variables.length; i++)
		tempString.push(this.variables[i].join("="));
		
	return tempString.join("&");
}
Flash.prototype.toString = function(){
	
	this.params.flashVars = this.getFlashVars();
	if(Browser.isIE()){
		//IE
		this.html = "<ob" + "ject";
		var attr = Flash.getObjectByExceptions(this.attributes, ["type", "data"]);
		for(var i in attr) if(i.toString() != "extend") this.html += " " + i.toString() + " = \"" + attr[i] + "\"";
		this.html += "> ";
		var params = Flash.getObjectByExceptions(this.params, ["pluginurl", "extend"]);
		for(var i in params) if(i.toString() != "extend") this.html += "<param name=\"" + i.toString() + "\" value=\"" + params[i] + "\" /> ";
		this.html += " </obj" + "ect>";
	} else {
		//non-IE
		this.html = "<!--[if !IE]> <--> <obj" + "ect";
		var attr = Flash.getObjectByExceptions(this.attributes, ["classid", "codebase"]);
		for(var i in attr) if(i.toString() != "extend") this.html += " " + i.toString() + " = \"" + attr[i] + "\"";
		this.html += "> ";
		var params = Flash.getObjectByExceptions(this.params, ["extend"]);
		for(var i in params) if(i.toString() != "extend") this.html += "<param name=\"" + i.toString() + "\" value=\"" + params[i] + "\" /> ";
		this.html += " </obj" + "ect> <!--> <![endif]-->";
	}

	return this.html;
	
}
Flash.prototype.write = Flash.prototype.outIn = Flash.prototype.writeIn = function(w){
	if(typeof w == "string" && document.getElementById) var w = document.getElementById(w);
	if( w != undefined && w ) w.innerHTML = this.toString();
	else document.write( this.toString() );
}

//去除左右两端的空格
function trim(s)  
{return  s.replace(/(^\s*)|(\s*$)/g,  "");} 

function $(id){return document.getElementById(id);}

function TryThese(){
    for (i = 0; i < arguments.length; i++){
        try{
            return arguments[i]();
        }catch(e){}
    }
    return false;
}

function CreateXMLHTTP(){
    return TryThese(
        function() {return new ActiveXObject("Msxml2.XMLHTTP");},
        function() {return new ActiveXObject("Microsoft.XMLHTTP");},
        function() {return new XMLHttpRequest();}
    ) || false;
}

function SendRequest(url, param, method, echofun) {
    var xmlHTTP = CreateXMLHTTP();
    if (xmlHTTP){
        xmlHTTP.onreadystatechange = function()
        {
            if (xmlHTTP.readyState == 4 && xmlHTTP.status == 200){
                if (echofun!= null){
                    echofun(xmlHTTP.responseText);
                }
            }
        }
        xmlHTTP.open(method, url, true);
        xmlHTTP.setRequestHeader("Content-Length",param.length); 
        xmlHTTP.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
        xmlHTTP.send(encodeURI(param));    
    }else{
        NoXMLHTTP();
    }
}

function NoXMLHTTP(){
    alert("Sorry, your browser doesn't support XMLHTTP");
}
 
function selectTag(showContent,selfObj){
	// 操作标签
	var tag = document.getElementById("i_menu").getElementsByTagName("li");
	var taglength = tag.length;
	for(i=0; i<taglength; i++){
		tag[i].className = "menu";
	}
	selfObj.parentNode.className = "menu_over";
	// 操作内容
	for(i=0; j=document.getElementById("tagContent"+i); i++){
		j.style.display = "none";
	}
	document.getElementById(showContent).style.display = "block";
}

function checkbook(theform)
{  
   document.getElementById("showaddmsg").style.display = 'block'
	if (trim(theform.username.value)=='')
	{  
	document.getElementById("showaddmsg").innerHTML="主题不能为空";
		theform.username.focus();
		theform.username.value='';
		return false
	}
	if (trim(theform.content.value)=='')
	{  
	document.getElementById("showaddmsg").innerHTML="内容不能为空";
		theform.content.focus();
		theform.content.value='';
		return false
	}
	var param;
	param="feedback.asp?action=save";
	param += "&username=" + escape(trim(theform.username.value));
	param += "&content=" + escape(trim(theform.content.value));
 	document.getElementById("showaddmsg").innerHTML ="提交中…";
    SendRequest(param, param, "POST", 
                function(responseText){
					var f	= responseText.substring(0,1);
					if (f == "1"){
						document.getElementById("showaddmsg").innerHTML =responseText.substring(1);
						setTimeout("document.getElementById('showaddmsg').style.display = 'none';","10000");
						return false
					}
					else {
                        document.getElementById("showaddmsg").innerHTML ="发布成功";
						document.getElementById("username").value='';
						document.getElementById("content").value='';
						setTimeout("document.getElementById('showaddmsg').style.display = 'none';","10000");
						loadlist();
					}
                });
	return false
}

function loadlist()
{
	var param;
	param="feedback.asp";
	document.getElementById("showmsg").innerHTML="载入中...";
	SendRequest(param, param, "POST", 
                function(responseText){
                        document.getElementById("showmsg").innerHTML =responseText;   
                });
}

function chanagepage(t0)
{
	var param;
	param="feedback.asp";
	param += "?page=" + escape(t0);
	document.getElementById("showmsg").innerHTML="载入中...";
	SendRequest(param, param, "POST", 
                function(responseText){
                        document.getElementById("showmsg").innerHTML =responseText;   
                });
}
