function ajaxLoad() {
var ajax = null; 
	try { ajax=new XMLHttpRequest(); }
	catch (e) { 
		try {
			ajax=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				ajax=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return ajax;
}

function uncache(url){
	var d = new Date();
	var time = d.getTime();
	return url + "&time="+time;
} 

function tagLoad(nome, language) {
	var ajax = ajaxLoad();
	if(language == 'en'){
		var url = uncache("http://www.matizar.com.br/en/_scripts/projetos_fluxo.php?tag="+nome);
	}
	else {
		var url = uncache("http://www.matizar.com.br/pt/_scripts/projetos_fluxo.php?tag="+nome);
	}
	ajax.open("GET", url);
	ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded; text/html; UTF-8");
	ajax.send(null);	
	ajax.onreadystatechange = function() {
		if(ajax.readyState == 4 ) {	
			if (ajax.status == 200) {
				document.getElementById("content").innerHTML = "		﻿" + ajax.responseText;
			}
		}
	}


/*

	var url = uncache("../_scripts/projetos_fluxo.php?tag="+nome);
	$.get(url, function(data){ document.getElementById("content").innerHTML = "		﻿" + data; });


*/
}

var jobToShare; // for shareThis purpouses
function jobLoad(job_selected) {
	jobToShare = job_selected; // for shareThis purpouses
	var ajax = ajaxLoad();
	ajax.open("GET", job_selected, false);
	ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded; text/html; UTF-8");
	ajax.send(null);
	if(ajax.readyState == 4 ) {
		if (ajax.status == 200) {
			document.getElementById("job").innerHTML = ajax.responseText;
			minimize_infos();
			C("#job").show();
			C("#job").animate({height: "790px",top: "195px"}, 1000, "linear", function(){ bindExit(); insertFlash(job_selected); });
		}
	}
}

function bindExit() {
	C("#more_projects").bind("click",function () { 
		C("#job").animate({height: "5px",top: "894px"}, 1000, "linear", function(){ C("#job").hide(); } );
    });
}

function minimize_infos() {
	C("#accordion p:first").addClass("active");
	C("#accordion p:not(:first)").hide();
	C("#accordion img").click(function(){
		C(this).next("p").slideToggle("slow").siblings("p:visible").slideUp("slow");
		C(this).toggleClass("active");
		C(this).siblings("p").removeClass("active");
	});
}


function insertFlash(nome) {
	var endereco = "endereco=../../_img/projetos/" + nome.replace(/.html/, "");
	var embed = document.createElement('embed');
	embed.setAttribute('wmode', 'opaque');
	embed.setAttribute('width',578);
	embed.setAttribute('height',450);
	//embed.setAttribute('src',"../../_img/projetos/_flash/galeria_projetos.swf");
	embed.setAttribute('src',"../../_img/projetos/_flash/galeria_projetos2.swf");
	embed.setAttribute('FlashVars', endereco);
	document.getElementById("videos").appendChild(embed);
}


function insertShareThis() {   
	var headID = document.getElementsByTagName("head")[0];
	var newScript = document.createElement('script');
	newScript.type = 'text/javascript';
	newScript.src = 'http://w.sharethis.com/widget/?tabs=web%2Cpost%2Cemail&amp;charset=utf-8&amp;services=%2Cdelicious%2Cfacebook%2Cstumbleupon%2Cmyspace%2Cgoogle_bmarks%2Cdigg%2Cyahoo_bmarks%2Cfriendfeed%2Creddit%2Cnewsvine%2Cwindows_live%2Cyahoo_myweb%2Cmagnolia%2Cblinklist%2Cfurl%2Ctechnorati%2Cfaves%2Cmixx%2Csimpy%2Cslashdot%2Ccurrent%2Cmister_wong&amp;style=default&amp;publisher=a0e65dfa-ef72-4beb-955b-21651e76f0a4&amp;headerbg=%23545454&amp;inactivebg=%23b8b8b8&amp;inactivefg=%23636363&amp;linkfg=%23878787&amp;embeds=true&amp;offsetLeft=100&amp;offsetTop=-190';
	headID.appendChild(newScript);
	
	document.getElementById("videos").appendChild("SHARETHIS.addEntry({title:'Matizar',url:'jobToShare', }, {button:true});");
}
