nn4=(document.layers)?1:0;
nn6=(document.getElementById&&!document.all)?1:0;
op5=(document.all&&!document.styleSheets)?1:0;
ie5=(document.getElementById&&!nn6&&!op5)?1:0;
ie4 = (document.all);
ns4 = (document.layers);


tempX=tempY=0;

var IE = false;
if (navigator.appName == "Microsoft Internet Explorer"){
	IE = true
}
if (!ie4){
	document.captureEvents(Event.MOUSEMOVE)
}
//document.onmousemove = getMouseXY;

function getMouseXY(m){
	if (IE) {
		var tmpX = event.clientX;
		var tmpY = event.clientY;
	} else {
		var tmpX = m.pageX;
		var tmpY = m.pageY;
	} 
	if (!document.body.scrollTop){
		var iL = document.documentElement.scrollLeft; 
		var iV = document.documentElement.scrollTop;
	} else {
		var iL = document.body.scrollLeft; 
		var iV = document.body.scrollTop; 
	}
	tempX= tmpX + iL;
	tempY= tmpY + iV;
}

/* dryes [at] criticalmass.com */
function FlashLibrary(){
    var t = this;
    var activeX = false;
    t.ieAutoInstall = false;
    t.hasVersion = function(ver){
        t.swf = false;
        if(!ver) ver = 0;
        var n = navigator;
        if(n.plugins && n.plugins.length > 0){
            var m,tp,d,v;
            m = n.mimeTypes;
            tp = 'application/x-shockwave-flash';
            if(m && m[tp] && m[tp].enabledPlugin && m[tp].enabledPlugin.description){
                d = m[tp].enabledPlugin.description;
                v = d.charAt(d.indexOf('.')-1);
                t.swf = (v >= ver) ? true : false;
            }
        }else if(n.appVersion.indexOf("Mac") == -1 && window.execScript){
            for(var i=ver; i<=7&&i!=1&&t.swf!=true; i++){
                execScript('on error resume next: flash.swf=IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash'+((i==0)?'':'.'+i)+'"))','VBScript');
            }
            if(t.swf) {
                activeX = true;
           }

        }else{
            t.swf = false;
        }
        return t.swf;
    }
    t.getPluginTag = function(swfFile,width,height,bgcolor,ver,altFormat,params,name,pTags){
        var s = '';
        var safari = (navigator.userAgent.toLowerCase().indexOf('safari') != - 1);
        var win = (navigator.appVersion.toLowerCase().indexOf("win")!=-1);
        var ie = (navigator.appName=="Microsoft Internet Explorer");
        if(!ie || (t.hasVersion(ver) && swfFile || (win && ie && swfFile && t.ieAutoInstall))){
            var additionalParams = '';
            if(params && params.length>0){
                var pArray = params.split(",");
                for(var i=0; i<pArray.length; i++){
                    var ta = pArray[i].substr(0,pArray[i].indexOf('='));
                    var v = pArray[i].substr(pArray[i].indexOf('=')+1,pArray[i].length);
                    additionalParams += (activeX)?'\t<param name="' + ta + '" value="' + v + '" />\n': ' '+ ta + '="' + v + '"';
                }
            }
            if(activeX){
                s = '<object id="flashObj'+name+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,21,0" width="'+width+'" height="'+height+'" '+pTags+'>\n';
                s += '\t<param name="movie" value="'+swfFile+'" />\n';
                s += '\t<param name="quality" value="high" />\n';
                s += '\t<param name="menu" value="false" />\n';
                s += '\t<param name="bgcolor" value="'+bgcolor+'" />\n';
                s += additionalParams;
                s += altFormat;
                s += '</object>\n';
                return s;
            }else{
                s = '<embed id="flashObj" src="'+swfFile+'" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'"'+additionalParams+(safari?' class="safari"':'')+'></embed>\n';
                return s;
            }
        }else{
            return altFormat;
        }
    }
    t.embedMovie = function(swfFile,width,height,bgcolor,ver,altFormat,params,name,pTags,retu){ 
		if(retu)
			return flash.getPluginTag(swfFile,width,height,bgcolor,ver,altFormat,params,name,pTags);
		else
	        document.write(flash.getPluginTag(swfFile,width,height,bgcolor,ver,altFormat,params,name,pTags)); 
    } 
}
var flash = new FlashLibrary();


/*					LOCALIZACAO							*/

var map;
var i=0;
var icons=Array();

function createMarker(point, icon, htmlText) {
	var infoTabs = [
	  new GInfoWindowTab("tab"+(i+1), htmlText)
	];
  var marker = new GMarker(point,icon.icon);
  GEvent.addListener(marker, "click", function() {
	marker.openInfoWindowTabsHtml(infoTabs);
  });
  map.addOverlay(marker);
  marker.openInfoWindowTabsHtml(infoTabs);
}
function mapIcon(obj){
	var new_icon = new GIcon();
		new_icon.image = obj.src;  
		new_icon.size = new GSize(obj.w,obj.h);
		new_icon.iconAnchor = new GPoint(obj.x,obj.y);
		new_icon.infoWindowAnchor = new GPoint(obj.xi,obj.yi);

	var opt = {};
		opt.icon = new_icon;
		opt.draggable = false;
		opt.clickable = true;
		opt.dragCrossMove = false;
		opt.title=obj.title;
	
	return opt;
}
function load_maps(l) {
  if (GBrowserIsCompatible()) {
	m=document.getElementById(l==undefined? "map" : l);
	if(m!=undefined){
		icons.push(mapIcon({src: "imagens/map/michele.png",			 	title: "Michele Canez",					w: 60, h: 60, x: 16, y : 40, xi: 30, yi: 2}));
		icons.push(mapIcon({src: "imagens/map/pontoRef.png", 			title: "Ponto de refer&ecirc;ncia"	, 	w: 32, h: 40, x: 16, y : 40, xi: 18, yi: 2}));
		
		
		map = new GMap2(m);

		map.enableDoubleClickZoom();
		map.enableContinuousZoom();
		map.enableScrollWheelZoom();

		var mapTypeControl = new GMapTypeControl();
		map.addControl(mapTypeControl);

		var mapLargeControl = new GLargeMapControl();
		map.addControl(mapLargeControl);

		pointCenter=new GLatLng(-27.12971557016348, -48.60545217990875);
		map.setCenter(pointCenter, 15);

		map.setMapType(G_HYBRID_MAP);

		createMarker(new GLatLng(-27.12756715701816, -48.601890206336975),icons[1],"<div class='texto'><b>Cal&ccedil;ad&atilde;o Praia Shopping</b></div>");
		createMarker(new GLatLng(-27.128636594498637, -48.60106408596039),icons[1],"<div class='texto'><b>Shopping Russi & Russi</b></div>");
		createMarker(new GLatLng(-27.129276342388177, -48.60431492328644),icons[1],"<div class='texto'><b>Caixa Econ&ocirc;mica Federal</div>");
		createMarker(new GLatLng(-27.129963828577683, -48.600372076034546),icons[1],"<div class='texto'><b>Banco Bradesco</b></div>");
		createMarker(new GLatLng(-27.128402655923675, -48.60182583332062),icons[1],"<div class='texto'><b>Restaurante Alberto&prime;s</b></div>");
		createMarker(new GLatLng(-27.127906131612338, -48.60902488231659),icons[1],"<div class='texto'><b>Supermercado Koch</b></div>");
		createMarker(new GLatLng(-27.132441608315954, -48.60896587371826),icons[1],"<div class='texto'><b>Posto de Combust&iacute;vel Petrobras</b></div>");
		createMarker(new GLatLng(-27.13067995553055, -48.60631585121155),icons[1],"<div class='texto'><b>Golden Gol</b></div>");
		createMarker(new GLatLng(-27.130011570517222, -48.60535025596619),icons[1],"<div class='texto'><b>Auto Pe&ccedil;as Zec&atilde;o</b></div>");
		createMarker(new GLatLng(-27.13122898308846, -48.60683083534241),icons[1],"<div class='texto'><b>Academia New Corpore</b></div>");
		createMarker(new GLatLng(-27.12971557016348, -48.60545217990875),icons[0],"<div class='texto'><b>Michele Canez<br>Fotografia Profissional</b><br><br>Rua 246, n&deg; 406 - Sala 1<br>Meia Praia - Itapema - SC</div>");

	}
  }
}

// MENSAGENS FORM.JS

msg					=Array();
msg["nome"]			="Preencha o campo Nome corretamente.";
msg["email"]		="Preencha o campo E-mail corretamente com e-mail válido.";
msg["cidade"]		="Preencha o campo Cidade corretamente.";
msg["uf"]			="Preencha o campo UF corretamente.";

function trim (valor) { 
	return valor.replace(/^\s+|\s+$/, ''); 
}

function validaForm(name){
	form=eval("document."+name+"Form");
	tderror=document.getElementById("error");
	eval("valida_"+name+"();");	
}
function validaForm_erro(mensagem,field){
	if(tderror==undefined)
		alert(mensagem);
	else 
		tderror.innerHTML=mensagem;
	field.focus();
}
function validaForm_send(){
	form.submit();	
}

function valida_depoimento(){
	campos=Array("nome","email","cidade","uf");
	for(cp=0;cp<campos.length;cp++){
		eval("var "+campos[cp]+"=form."+campos[cp]);
	}
	if(trim(nome.value).length<3){
		validaForm_erro(msg["nome"],nome);
	} else if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email.value)==false){
		validaForm_erro(msg["email"],email);
	} else if(trim(cidade.value).length<3){
		validaForm_erro(msg["cidade"],cidade);
	} else if(trim(uf.value).length<2){
		validaForm_erro(msg["uf"],uf);
	} else {
		validaForm_send();
	}
}

/*				AJAX				*/
try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}

function ajaxRead(url,funcao,retorna){
    xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange=function(){
        if (xmlhttp.readyState==4){
			var texto=xmlhttp.responseText;
			texto=unescape(texto.replace(/\+/g," "));
			//alert(texto);
			eval(funcao);
			if(retorna!=undefined)
				return texto==retorna;
        }
    }
    xmlhttp.send(null);
}

var objM;
var objMB;
var objF;
var objO;
var objOB;
var objC;
var objCB;


function loadInit(){
	objM	=document.getElementById("map");
	objMB	=document.getElementById("mapBtn");
	objF	=document.getElementById("fundoMap");
	objO	=document.getElementById("online");
	objOB	=document.getElementById("onlineBtn");
	objC	=document.getElementById("centro");
	objCB	=document.getElementById("centroBtn");
}

iniciado=false;
function openMap(){
	closeOnline();
	
	if(!iniciado)
		load_maps();

	objMB.style.visibility=objF.style.visibility=objM.style.visibility="visible";
	iniciado=true;
}
function closeMap(){
	objMB.style.visibility=objF.style.visibility=objM.style.visibility="hidden";
}

function openOnline(){
	objF.style.visibility=objOB.style.visibility=objO.style.visibility="visible";
}
function closeOnline(){
	objF.style.visibility=objOB.style.visibility=objO.style.visibility="hidden";
}

function openCentro(cod,local,pag,result){
	if(result==undefined){
		pag=(pag==undefined)? 1 : pag;
		ajaxRead("arquivos/centro.php?cod="+cod+"&l="+local+"&pag="+pag,'openCentro(false,false,'+pag+',texto);',true);
	} else {
		objC.innerHTML=result;
		initLightbox();
		objF.style.visibility=objCB.style.visibility=objC.style.visibility="visible";
	}
}
function closeCentro(){
	objF.style.visibility=objCB.style.visibility=objC.style.visibility="hidden";
	objC.innerHTML="";
}