
//http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/activating_activex.asp

var https= "";
function abrirflash(obj_swf, obj_wmode, obj_widht, obj_height,idobj)
{
	var obj= '     <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http' + https + '://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="'+obj_widht+'" HEIGHT="'+obj_height+'" id="dhtml' + obj_widht + '_' + obj_height + '" ALIGN="">';
	obj= obj + '       <PARAM NAME="movie" VALUE="'+obj_swf+'">';
	obj= obj + '       <PARAM NAME="quality" VALUE="high">';
	obj= obj + '       <PARAM NAME="wmode" VALUE="'+obj_wmode+'">';
	obj= obj + '      <EMBED src="'+ obj_swf +'" quality="high" wmode="'+obj_wmode+'" bgcolor="#FFFFFF"  WIDTH="'+obj_widht+'" HEIGHT="'+obj_height+'" NAME="swflogomarca" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http' + https + '://www.macromedia.com/go/getflashplayer"></EMBED>';
	obj= obj + '     </OBJECT>';
	
	document.getElementById(idobj).innerHTML= obj;
	//document.writeln(obj);
}

function abrirFlashMascara(obj_swf, obj_wmode, obj_widht, obj_height, obj_link,idobj)
{
	var obj= '<div style="position:absolute;width:' + obj_widht + 'px;height:' + obj_height + 'px;z-index:10;"><a href="'+ obj_link +'"><img src="imgs/geral/transp.gif" width="'+ obj_widht +'" height="'+ obj_height +'" border="0"></a></div>';
	if (obj_link=="")
		obj="";
		
	obj= obj + '    <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http' + https + '://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="'+obj_widht+'" HEIGHT="'+obj_height+'" id="swfbanner' + obj_widht + '_' + obj_height + '" ALIGN="">';
	obj= obj + '       <PARAM NAME="movie" VALUE="'+obj_swf+'">';
	obj= obj + '       <PARAM NAME="quality" VALUE="high">';
	obj= obj + '       <PARAM NAME="wmode" VALUE="'+obj_wmode+'">';	
	obj= obj + '      <EMBED src="'+ obj_swf +'" quality="high" wmode="'+obj_wmode+'" WIDTH="'+obj_widht+'" HEIGHT="'+obj_height+'" NAME="swfbanner" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http' + https + '://www.macromedia.com/go/getflashplayer"></EMBED>';
	obj= obj + '     </OBJECT>';
	
	document.getElementById(idobj).innerHTML= obj;
	//document.writeln(obj);
}

function abrirImagem(obj_img, obj_widht, obj_height, obj_link,idobj)
{
	var imgrm= new Image;
	imgrm.src= obj_img;
	var obj= '<a href="' + obj_link + '" target="_new"><img src="' + imgrm.src + '" width="' + obj_widht + '" height="' + obj_height + '" border="0" /></a>';
	document.getElementById(idobj).innerHTML= obj;
}


function abrirObjeto(obj_peca, obj_widht, obj_height, obj_tipo_id, obj_link,idobj)
{
	//de acordo com o tipo, vamos chamar uma função especifica.
	//3-SWF
	if (obj_tipo_id==3)
	{
		//vamos chamar a função que abre o SWF
		var obj_wmode= "Transparent";
		abrirFlashMascara(obj_peca, obj_wmode, obj_widht, obj_height, obj_link,idobj);
	}

    //1-GIF; 2-JPG
	if ((obj_tipo_id==1)||(obj_tipo_id==2))
	{
		//vamos chamar a função que abre a img
		abrirImagem(obj_peca, obj_widht, obj_height, obj_link,idobj);
	}
}

var pos= -1;
function criarArray(pos)
{
    var arRay;
	arRay=new Array(pos);
	var i= 0;
	for (i=0; i<arRay.length; i++)
	{
		arRay[i]= new Array(5);
	}
	return(arRay);
}

var isCliqueLink= 0;
var funcao="next";
var idTimeTV= 0;
function scheduleTV(tipo)
{
	if (tipo==1)
	{
        idTimeTV= window.setTimeout("refreshTV();",33100);	
	}
	else
	{
		window.clearTimeout(idTimeTV);
	}
}

function refreshTV()
{
	if (isCliqueLink==0)
	{
		//aqui vamos decidir se vamos pra frente ou prar traz.
		if(funcao=="next")
		{
			pos= pos + 1;
			if (pos == artv.length)
				pos= 0;
		}
		if(funcao=="back")
		{
			pos = pos - 1;
			if (pos < 0)
				pos= artv.length-1;
		}
		
		//aqui vamos chamar a apresentação da TV
		abrirObjeto(artv[pos][0], artv[pos][1], artv[pos][2], artv[pos][3], artv[pos][4],"spanTV");
		//aqui vamos schedular a próxima chamada da tv.
		scheduleTV(1);
	}
	else
	{
		//aqui vamos desabilitar a chamada da tv.
		scheduleTV(0);
	}
}

function tvnext()
{
	funcao="next";
	isCliqueLink=0;
	scheduleTV(0);//parar schedule
	refreshTV(); //apresentar tv
}

function tvback()
{
	funcao="back";
	isCliqueLink=0;
	scheduleTV(0);//parar schedule
	refreshTV(); //apresentar tv
}

function tvpause()
{
	isCliqueLink= 1;
	scheduleTV(0);//parar schedule
	document.getElementById("linktvpausa").style.display= "none";
	document.getElementById("linktvplay").style.display= "";
}

function tvplay()
{
	isCliqueLink= 0;
	refreshTV();
	document.getElementById("linktvpausa").style.display= "";
	document.getElementById("linktvplay").style.display= "none";
}

function apresentaSKY()
{
	var pos=0;
	var idobj;
	var quebralinha="";
    //aqui vamos montar os objetos que serao usados
	while (pos < arsky.length)
	{
	    idobj= "spanSKY" + pos;
	    if (pos>0)
	        quebralinha= "<div style='height:5px' class='cssMenuAcesso'></div>";
	        
	    document.getElementById("spanSKY").innerHTML= document.getElementById("spanSKY").innerHTML + quebralinha + "<span id='" + idobj + "'></span>";
	    pos= pos + 1;
	}
    pos=0;
	//aqui vamos chamar a apresentação do SKY
	while (pos < arsky.length)
	{
	    idobj= "spanSKY" + pos;
	    abrirObjeto(arsky[pos][0], arsky[pos][1], arsky[pos][2], arsky[pos][3], arsky[pos][4],idobj);
	    pos= pos + 1;
	}
}

var pidAtual=0;
var urlDetalhe;
//function viewPH(pid)
function viewPH (pid, cid, pai_id, nomePlano, espaco_disco, transferencia_mensal, contas_email, bancomysql, bancosqlserver, preco)
{   
    pidAtual= pid;
    //alert(document.getElementById("lph" + pid).innerHTML);
    document.getElementById("lph" + pid).focus();
    //" + document.getElementById("lph" + pid).innerHTML
    urlDetalhe= "phconsulta.aspx?pid2=" + pid + "&cid=" + cid + "&paid=" + pai_id + "&titulo=Planos-de-Hospedagem/Corporativo-Light";
    document.getElementById("tdED").innerHTML= espaco_disco;
    document.getElementById("tdTM").innerHTML= transferencia_mensal;
    document.getElementById("tdCE").innerHTML= contas_email;
    document.getElementById("tdMySQL").innerHTML= bancomysql;
    document.getElementById("tdSQLserver").innerHTML= bancosqlserver;
    document.getElementById("tdPreco").innerHTML= preco;
}

function contratarPH()
{
    if (pidAtual==0)
    {
        alert("Prezado cliente, por favor, selecione um plano ao lado, para que você possa iniciar o processo de contratação.");
    }
    else
    {
        location.href= urlDetalhe;
    }
}

function tvdetalhes(id)
{
	//alert(id);
	var urldest;
	if (id==1)
	    urldest = "pgproduto.aspx?catid=270&paid=0&ctid=3&titulo=Cozinhas";
	if (id==2)
	    urldest = "pgproduto.aspx?catid=265&paid=0&ctid=3&titulo=Areas-de-Servico";
	if (id==3)
	    urldest = "pgproduto.aspx?catid=266&paid=0&ctid=3&titulo=Banheiros";
	if (id==4)
	    urldest = "pgproduto.aspx?catid=273&paid=0&ctid=3&titulo=Dormitorios";
	if (id==5)
	    urldest = "pgproduto.aspx?catid=274&paid=0&ctid=3&titulo=Home-Theater";
	if (id == 6)
	    urldest = "pgproduto.aspx?catid=271&paid=0&ctid=3&titulo=Corporativo";
	
	location.href= urldest;
}

