var global = new Object();global = {	/**Adiciona ../ até alcançar a raiz do site. Útil para se construir caminho relativos a partir da raiz*/ 	RelativeRoot: function(){		var strHref = window.location.pathname;		var bar = 0;		var path = '';		for(n=0;n!=strHref.length;n++){			if (strHref.charAt(n)=='/'){				bar++;			}		}		if( bar < 2 ){			return path;		}		for(n=1;n!=bar;n++){			path = '../' + path;		}		return path;	},	isSubDomain: function(){		var strf = window.location.hostname;		var p = strf.indexOf('.');		var sub = strf.substring(0,p);		var is = (sub!="www" && sub!="gamevicio" ? true : false);		return is;	},	form: {		CreateQuery: function(formId){	   		var elements = formId.elements ? formId.elements : document.forms[formId].elements;	        var pairs = new Array();		    for (var i = 0; i < elements.length; i++) {		        if ((name = elements[i].name) && (value = elements[i].value))		            pairs.push(name + "=" + encodeURIComponent(value));		    }		    return pairs.join("&");		}	},	cookie : {		Read: function(name){			var cookieValue = "";			var search = name + "=";			if(document.cookie.length > 0) {		    		offset = document.cookie.indexOf(search);		   		 if (offset != -1) {					offset += search.length;		      			end = document.cookie.indexOf(";", offset);		      			if (end == -1) end = document.cookie.length;		      			cookieValue = unescape(document.cookie.substring(offset, end))		    		}		 	}			return cookieValue;		},		Write: function (name, value, hours, path, domain, secure){			var cookie = "";			cookie+= name + "=" + escape(value);			if(hours != null) {				expire = new Date((new Date()).getTime() + hours * 3600000);				expire = "; expires=" + expire.toGMTString();			}else{				expire = "";			}			cookie+= expire;			cookie+= ((path) ? "; path=" + path : "");			cookie+= ((domain) ? "; domain=" + domain : "");		      cookie+= ((secure) ? "; secure" : "");			document.cookie = cookie;		}	},	div: {		Write: function(divId,content){			var d = document.getElementById(divId);			if (d){				d.innerHTML = content;			}		},		WriteAdd: function(divId,content){			var d = document.getElementById(divId);			if (d){				d.innerHTML+= content;			}		},		Shrink: function(divId,mode){			switch (mode){				case 0:					s = document.getElementById(divId).style.display == "none" ? "" : "none";					break;				case 2:					s = "none";					break;				case 1:					s = "";					break;			}			document.getElementById(divId).style.display = s;		},		Read: function(divId){			if (document.getElementById(divId)){				return document.getElementById(divId).innerHTML;			}else{				return "";			}		}	},	utf8: {		encode : function (string) {	        string = string.replace(/\r\n/g,"\n");	        var utftext = "";	        for (var n = 0; n < string.length; n++) {	            var c = string.charCodeAt(n);	            if (c < 128) {	                utftext += String.fromCharCode(c);	            }	            else if((c > 127) && (c < 2048)) {	                utftext += String.fromCharCode((c >> 6) | 192);	                utftext += String.fromCharCode((c & 63) | 128);	            }	            else {	                utftext += String.fromCharCode((c >> 12) | 224);	                utftext += String.fromCharCode(((c >> 6) & 63) | 128);	                utftext += String.fromCharCode((c & 63) | 128);	            }	        }	        return utftext;    	},	    decode : function (utftext) {	        var string = "";	        var i = 0;	        var c = c1 = c2 = 0;	        while ( i < utftext.length ) {	            c = utftext.charCodeAt(i);	            if (c < 128) {	                string += String.fromCharCode(c);	                i++;	            }	            else if((c > 191) && (c < 224)) {	                c2 = utftext.charCodeAt(i+1);	                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));	                i += 2;	            }	            else {	                c2 = utftext.charCodeAt(i+1);	                c3 = utftext.charCodeAt(i+2);	                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));	                i += 3;	            }	        }	        return string;	    }	},	getUrlVars: function (){		var vars = [], hash,s;		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1);		var anchor = hashes.indexOf('#');		if (anchor>-1){			hashes = hashes.slice(0,anchor);		}		hashes = hashes.split('&');		for(var i = 0; i < hashes.length; i++){			hash = hashes[i].split('=');			vars.push(hash[0]);			vars[hash[0]] = hash[1];		}		var hashes2 = window.location.href.slice(window.location.href.indexOf('#') + 1).split('&');		for(var i = 0; i < hashes2.length; i++){			hash = hashes2[i].split('=');			vars.push(hash[0]);			vars['#'+hash[0]] = hash[1];		}		return vars;	},	evalScripts: function(s){		var p = b = e = c = g = 0;		var sBegin = '<script';		var sEnd = '</script>';		while((b=s.indexOf(sBegin,p))!=-1){			e = s.indexOf(sEnd,p);			if (e==-1){				break;			}			g = s.indexOf('>',b);			//c = s.substr(b+sBegin.length,e-(b+sBegin.length));			c = s.substr(g+1,e-(g+1));			p = e + sEnd.length;			eval(c);		}	},	event: {		addLoad: function(func){			var oldonload = window.onload;			if (typeof window.onload != 'function'){		    	window.onload = func;			} else {				window.onload = function(){				oldonload();				func();				}			}		},		addScroll: function(func){			var oldonload = window.onscroll;			if (typeof window.onscroll != 'function'){		    	window.onscroll = func;			} else {				window.onscroll = function(){				oldonload();				func();				}			}		}	}}var tab = new Object();tab = {	id: new Array(0,0,0,0,0,0,0,0,0),	COOKIE_LAYER:true,	start: function(area){		if (tab.COOKIE_LAYER){			var r = global.cookie.Read(area+'_last_tab');			if (r.length>0){				tab.change(area,r);			}		}		//alert(tab.getId('video'));	},	areaToId:function(area){		var n=0;		switch(area){			case "news":				n=0;				break;			case "video":				n=1;				break;			case "trans":				n=2;				break;			case "rev":				n=3;				break;			case "rel":				n=4;				break;			case "gv":				n=5;				break;			case "forum":				n=6;				break;			case "down":				n=7;				break;			case "search":				n=8;				break;		}		return n;	},	setId: function(area,n){		tab.id[tab.areaToId(area)] = n;	},	getId: function(area){		return tab.id[tab.areaToId(area)];	},	change: function(area,id){		if (tab.getId(area)==id){			return;		}		var oldId = tab.getId(area);		tab.setId(area,id);		if (tab.COOKIE_LAYER){			global.cookie.Write(area+"_last_tab",id,24*30,"/",".localhost",false);		}		if (oldId>-1){			global.div.Shrink(area+'_tab_content_'+oldId,0);			document.getElementById(area+'_tab_'+oldId).className = 'tab_off';		}		global.div.Shrink(area+'_tab_content_'+id,1);		document.getElementById(area+'_tab_'+id).className = 'tab_on';		document.getElementById(area+'_tab_'+id).blur();	}}
