var flashPlugin = ( (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0 );
if(flashPlugin) {
	flashPlugin = parseInt(flashPlugin.description.substring(flashPlugin.description.indexOf(".")-1)) >= 6;
} else if(navigator.userAgent && navigator.userAgent.indexOf("MSIE") >= 0 && (navigator.userAgent.indexOf("Windows 95") >= 0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT") >= 0)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('ON ERROR RESUME NEXT\n');
	document.write('flashPlugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5")) )\n');
	document.write('IF (flashPlugin <= 0) THEN flashPlugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")) )\n');
	document.write('ON ERROR GOTO 0\n');
	document.write('<\/SCR' + 'IPT\> \n');
}
function flash(swf, width, height) {
	if(flashPlugin) {
		document.write('<object width="' + width + '" height="' + height + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0">');
		document.write('<param name="movie" value="' + swf +'" />');
//		document.write('<param name="wmode" value="transparent" />');
		document.write('<param name="quality" value="high" />');
		document.write('<embed src="' + swf +'" width="' + width + '" height="' + height + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash">');
		document.write('</embed>');
		document.write('</object>');
	} else {
		swf = swf.substr(0, swf.indexOf(".") == -1 ? swf.length : swf.lastindexOf(".") );
		document.write('<a href="' + swf + '.map"><img src=' + swf + '.gif" width="' + width + '" height="' + height + '" alt="' + swf + '" ismap="ismap" /></a>');
	}
}
function criatividade_pg(n, max)
{
	if(!document.getElementById) return;
	for(var i = 1; i <= max; i++) {
		var obj1 = document.getElementById("pg"  + i);
		var obj2 = document.getElementById("lnk" + i);
		if(obj1 != null && obj2 != null) {
			obj1.className = ( i != n ? "hide"    : "" );
			obj2.className = ( i == n ? "current" : "" );
		}
	}
}
function criatividade_home(src, url, alt)
{
	var obj = ( document.getElementById ? document.getElementById("show") : null );
	if(obj != null) {
		var html = "";
var url = 'site.php?destino=criacoes#' + src.replace(/^.+\/([0-9]+)_2\.jpg$/, "$1");
		if(url != "") html+= '<a href="' + url + '">'; // onclick="this.target=\'_BLANK\'; return true;"
		html+= '<img src="' + src + '" width="490" height="155" alt="' + alt + '" />';
		if(url != "") html+= '</a>';
		obj.innerHTML = html;
	}
}
function criatividade_show(img_id, max)
{
	var obj = ( document.getElementById ? document.getElementById("show") : null );
	if(obj != null && typeof(criatividades) == "object" && typeof(criatividades[img_id]) == "object") {

		criatividade_pg(criatividades[img_id].pg, max);

		var html = '';

		html+= '<span id="anterior">';
		if(criatividades[img_id].anterior != 0) html+= '<a href="' + criatividades[criatividades[img_id].anterior].src + '" onclick="criatividade_show(' + criatividades[img_id].anterior + ', '+ max  +'); return false;">';
		html+= '&lt;&lt;';
		if(criatividades[img_id].anterior != 0) html+= '</a>';
		html+= '</span>';

		html+= '<span id="proximo">';
		if(criatividades[img_id].proximo  != 0) html+= '<a href="' + criatividades[criatividades[img_id].proximo ].src + '" onclick="criatividade_show(' + criatividades[img_id].proximo  + ', '+ max  +'); return false;">';
		html+= '&gt;&gt;';
		if(criatividades[img_id].proximo != 0) html+= '</a>';
		html+= '</span>';

		if(criatividades[img_id].link != "") html+= '<a href="' + criatividades[img_id].link + '" onclick="this.target=\'_BLANK\'; return true;">';
		html+= '<img src="' + criatividades[img_id].src + '" width="' + criatividades[img_id].width + '" height="' + criatividades[img_id].height + '" alt="" />';
		if(criatividades[img_id].link != "") html+= '</a>';
		html+= '<br />';
		html+= '<br />';
		html+= '<b class="vermelho">' + criatividades[img_id].titulo + '</b><br />';
		html+= '<br />';

		obj.innerHTML = html;

		criatividade_desc(img_id);
	}
}
function criatividade_desc(id)
{
	var obj = ( document.getElementById ? document.getElementById("desc") : null );
	if(obj != null && typeof(criatividades) == "object" && typeof(criatividades[id]) == "object") {
		if(criatividades[id].desc == null) {
			ajax(id, "desc.php", "id=" + id, "GET", callback_criatividade_desc);
			obj.innerHTML = '';
		} else {
			obj.innerHTML = criatividades[id].desc;
		}
	}
}
function callback_criatividade_desc(id, request)
{
	if(typeof(request) == "undefined" || (typeof(request) == "boolean" && request == false)) { // Error
	} else if(request.readyState == 4) { // Complete
		if(typeof(criatividades) == "object" && typeof(criatividades[id]) == "object") {
			if(criatividades[id].desc == null) {
				criatividades[id].desc = request.responseText;
				criatividade_desc(id);
			}
		}
	}
}
function ajax(id, url, data, method, callBackFunction)
{
	var ajaxReq = new Object();
	ajaxReq.id = id;
	ajaxReq.callBackFunction = callBackFunction;
	ajaxReq.callBack = function () { ajaxReq.callBackFunction(ajaxReq.id, ajaxReq.xmlhttp); };
	ajaxReq.xmlhttp = false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
		try {
			ajaxReq.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				ajaxReq.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				ajaxReq.xmlhttp = false;
			}
		}
	@end @*/
	if(!ajaxReq.xmlhttp && typeof(XMLHttpRequest) != "undefined") ajaxReq.xmlhttp = new XMLHttpRequest();
	if(ajaxReq.xmlhttp) {
		if(method == "GET") {
			if(data.length > 0) url+= ( url.indexOf("?") == -1 ? "?" : "&" );
			querystring = data;
			post = null;
		} else if(method == "POST") {
			querystring = "";
			post = data;
		}
		if(method == "GET" || method == "POST") {
			ajaxReq.xmlhttp.open(method, url + querystring, true);
			ajaxReq.xmlhttp.onreadystatechange = ajaxReq.callBack;
			if(method == "POST" && typeof(ajaxReq.xmlhttp.setRequestHeader) != "undefined") {
				ajaxReq.xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			}
			ajaxReq.xmlhttp.send(post);
		} else {
			alert("AJAX Error:\nMethod \"" + method + "\" not allowed!");
		}
	} else {
		alert("AJAX Error:\nCould not initialize the XMLHTTP object.");
	}
}
function dropDefinitions()
{
	var n = 0;
	var dls = document.getElementsByTagName("DL");
	for(var i = 0; i < dls.length; i++) {
		if(dls[i].className == "dropDefinitions") {
			for(var j = 0; j < dls[i].childNodes.length; j++) {
				if(dls[i].childNodes[j].tagName == "DT") {
					n++;
					dls[i].childNodes[j].className = "pointer";
					dls[i].childNodes[j].onmouseover = function (e) { this.className = "hover " + this.className; };
					dls[i].childNodes[j].onmouseout  = function (e) { this.className = this.className.replace(/^hover /, ""); };
					eval("dls[i].childNodes[j].onclick = function (e) { " +
							"var obj = document.getElementById('dropDefinitionsDD" + n + "'); " +
							"if(obj == null) return; " +
							"obj.className  = ( obj.className == 'show' ? 'hide' : 'show' ); " +
							"this.className = ( obj.className == 'show' ? this.className + ' hover' : this.className.replace(/ hover$/, '') ); " +
						"};"
					);
				} else if(dls[i].childNodes[j].tagName == "DD") {
					dls[i].childNodes[j].id = "dropDefinitionsDD" + n;
					if(!dls[i].childNodes[j].style) dls[i].childNodes[j].style = dls[i].childNodes[j];
					dls[i].childNodes[j].className= "hide";
				}
			}
		}
	}
}
