// Function scripts
///////////////////////////
// uso geral 
////////////////////////////
function Trim(str){return str.replace(/^\s+|\s+$/g,"");}
////////////////////////////////////////////////////////

function conteudo(page,path_info) {
//  set_path_info (path_info);
  var serverPage = page;
  var areaID = "contentID";
  var str = "";
  processajax ("GET",serverPage,areaID, "");
}
function show_contato () {
 var serverPage = "contato.php";
  var areaID = "main";
  var str = "";
  processajax ("GET",serverPage,areaID, "");
}

//Conteudo para produto
function prodContent(page,path) {
  var serverPage = path+'conteudo/produtos/'+page+'.php?realod=true&ph='+path;
  var areaID = "contentID";
  var str = "";
  processajax ("GET",serverPage,areaID, "");
}
function show_acessorios (file) {
 var serverPage = "acessorios/"+file+".php";
  var areaID = "main";
  var str = "";
  processajax ("GET",serverPage,areaID, "");
}
function show_caracteristicas (file) {
 var serverPage = file+".php";
  var areaID = "main";
  var str = "";
  processajax ("GET",serverPage,areaID, "");
}
function show_catalogos (file) {
 var serverPage = "catalogos/"+file+".php";
  var areaID = "main";
  var str = "";
  processajax ("GET",serverPage,areaID, "");
}
function show_big (file) {
   var target = '../../includes/show_bigpicture.php?reload=true&file='+file;
   win = window.open(target,'PrintWindow','menubar=no,status=yes,location=no,width=700,height=400,resizable=yes,toolbar=no,scrollbars=yes');
   win.opener = self;
   win.window.focus();
}
function cotacao (CodProd) {
   var target = '../../contatoform1.php?reload=true&cot=1&cp='+CodProd;
   win = window.open(target,'WinCotacao','menubar=no,status=yes,location=no,width=480,height=520,resizable=yes,toolbar=no,scrollbars=yes');
   win.opener = self;
   win.window.focus();
}
function cotacao_produto (page) {
   var target = '../../contato/'+page;
   win = window.open(target,'WinCotacao','menubar=no,status=yes,location=no,width=480,height=580,resizable=yes,toolbar=no,scrollbars=yes');
   win.opener = self;
   win.window.focus();
}

function chgEspChar(valor){
	//Substituir caracteres especiais com acento para sem acento
var char_espin = ['à','è','ì','ò','ù','á','é','í','ó','ú','â','ê','î','ô','û','ä','ë','ï','ö','ü','ã','õ','ç','Ç','À','È','Ì','Ò','Ù','Á','É','Í','Ó','Ú','Â','Ê','Î','Ô','Û','Ä','Ë','Ï','Ö','Ü','Ã','Õ'];
var char_espout =['a','e','i','o','u','a','e','i','o','u','a','e','i','o','u','a','e','i','o','u','a','o','c','C','A','E','I','O','U','A','E','I','O','U','A','E','I','O','U','A','E','I','O','U','A','O'];
var retorno = valor;
for (i=0;i<46;i++){
	while(retorno.indexOf(char_espin[i]) >= 0) retorno = retorno.replace(char_espin[i],char_espout[i]);
}

return retorno;
}

function bookmark(tipo){
   var titulo = unescape(document.title);
   while(titulo.indexOf(" ") >= 0) titulo = titulo.replace(" ","+");
   titulo = chgEspChar(titulo);
   switch (tipo) {
	   case "google" :
			target = "http://www.google.com/bookmarks/mark?op=edit&amp;bkmk="+window.location+"&title="+titulo;
    		win = window.open(target,'Wingoogle','menubar=yes,status=yes,location=yes,resizable=yes,toolbar=yes,scrollbars=yes');
			break;			
	   case "yahoo" :
			target = "http://myweb2.search.yahoo.com/myresults/bookmarklet?t="+titulo+"&u="+window.location;
    		win = window.open(target,'WinYahoo','menubar=yes,status=yes,location=yes,resizable=yes,toolbar=yes,scrollbars=yes');
			break;
	   case "winlive" :
			target = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;mkt=en-us&amp;url="+window.location+"&amp;title="+titulo;
    		win = window.open(target,'WinLive','menubar=yes,status=yes,location=yes,resizable=yes,toolbar=yes,scrollbars=yes');
			break;
	   case "delicious" :
			target = "http://del.icio.us/post?url="+window.location+"&title="+titulo;
    		win = window.open(target,'WinDelicious','menubar=yes,status=yes,location=yes,resizable=yes,toolbar=yes,scrollbars=yes');
			break;
	   case "digg" :
			target = "http://digg.com/submit?phase=2&url="+window.location+"&title="+titulo;
    		win = window.open(target,'WinDigg','menubar=yes,status=yes,location=yes,resizable=yes,toolbar=yes,scrollbars=yes');
			break;
   }

    win.opener = self;
	win.window.focus();
	
}

function chgphoto(ref){
 if (document.getElementById('phonetype').innerHTML == '1'){
    document.getElementById('photo-ep450s').innerHTML = '<img src="imgs/flash/ep450_'+ref+'.jpg" width="350" height="360" alt="" name="EP450S">';
 }else {
    document.getElementById('photo-ep450s').innerHTML = '<img src="imgs/flash/ep450s_sem_display_'+ref+'.jpg" width="350" height="360" alt="" name="EP450S">';
 }
 //-Limpara temporizador animacao
 clearTimeout(timeout_state);
 timeout_state=null;

}
function chgphonetype(ref){
  if (document.getElementById('phonetype').innerHTML != ref){
    document.getElementById('phonetype').innerHTML = ref;
    chgphoto(1);
    thumbphotos(ref);
  }
 //-Limpara temporizador animacao
 clearTimeout(timeout_state);
 timeout_state=null;
 imageLoad(ref);
}

function thumbphotos(ref){
   var serverPage = "includes/menuthumbs.php?ref="+ref;
   var areaID = 'thumbphotos';
   var str = "";
   processajax ("GET",serverPage,areaID, "");
}
//------------------------
// ANIMACAO
//------------------------
function imageLoad(ref) {
    frame=0;
    for(var i=1; i<7; i++) {
    anims[i-1]=new Image();
        if (ref == '1'){
            anims[i-1].src="imgs/flash/ep450_" + i + ".jpg";
        } else {
            anims[i-1].src="imgs/flash/ep450s_sem_display_" + i + ".jpg";
        }
    }
    animator();
}
function animator() {
    var tsegundos = 3;
    document.EP450S.src = anims[frame].src;
    frame=frame+1;
    if (frame>5) frame=0;
    timeout_state=setTimeout("animator()",500*tsegundos);
}
function guia_produto() {
   var target = 'ep450s-tour.htm';
   win = window.open(target,'guiaProduto','menubar=no,status=yes,location=no,width=770,height=620,resizable=yes,toolbar=no,scrollbars=yes');
   win.opener = self;
   win.window.focus();
}

