function opWin(url,id,w,h,param) {
				t = (screen.height-h)/2;
				l = (screen.width-w)/2;
				nwin = window.open("" + url + "","","left=" + l + ","+ param +",top=" + t + ",width=" + w + ",height=" + h +"");
				nwin.focus();
}


function opAtend() {
    opWin('http://atendimento.minas.com.br/request.php?l=atendimento&x=1&deptid=2&page=http://www.minas.com.br/atendimento.html','0','450','365');
}

function chgClass(n,c) {
	n.className = c;
}

function rndClass(n) {
	if(n.className=='normal') {
		n.className = 'active';
	} else {
		n.className = 'normal';
	}
}

function chgImg(i,o) {
    document.getElementById(""+ i +"").src = o;
    return true;
}

function volta(url) {
    location.href=""+ url +"";
}

function showmsg(pstrMsg){
	document.getElementById('message_txt').innerHTML = pstrMsg;
}

function habilita(i,b,n,c) {
    
    document.getElementById("" + i +"").style.display = "block";
    document.getElementById("" + b +"").style.display = "none";
    document.getElementById("" + i +"").focus();
    document.getElementById("mlabel").style.display = "block";
	document.getElementById("mlabel").innerHTML = "Digite o " + document.getElementById(""+ n +"").value;
    document.getElementById("botao").style.display = "block";
    document.getElementById("" + c +"").style.width = "98px";
    document.getElementById("" + c +"").style.height = "54px";
    document.getElementById("" + n +"").style.width = "196px";
    document.getElementById("" + n +"").style.height = "108px";

}

var store = new Array();


store['Registro de Domínio (Internacional)'] = new Array(
	'Registro de Domínios','Registro'
);

store['Plano #1 (100 MB / 1 GB)'] = new Array(
	'Windows','Windows',
	'Linux','Linux'
);

store['Plano #2 (200 MB / 2 GB)'] = store['Plano #1 (100 MB / 1 GB)'];
store['Plano #3 (300 MB / 3 GB)'] = store['Plano #1 (100 MB / 1 GB)'];
store['Plano #4 (400 MB / 4 GB)'] = store['Plano #1 (100 MB / 1 GB)'];
store['Plano #5 (500 MB / 5 GB)'] = store['Plano #1 (100 MB / 1 GB)'];
store['Revenda #1 (1 GB / 10 GB)']  = store['Plano #1 (100 MB / 1 GB)'];
store['Revenda #2 (2 GB / 20 GB)'] = store['Plano #1 (100 MB / 1 GB)'];
store['Revenda #3 (3 GB / 30 GB)'] = store['Plano #1 (100 MB / 1 GB)'];
store['Revenda #4 (4 GB / 40 GB)'] = store['Plano #1 (100 MB / 1 GB)'];
store['Revenda #5 (5 GB / 50 GB)'] = store['Plano #1 (100 MB / 1 GB)'];


store['Dedicado #1 (Celeron 2.0 / 1 GB / 2 x 80 GB / 1000 GB)'] = new Array(
	'Linux','Linux'
);

store['Dedicado #2 (P4 2.4 / 1 GB / 2 x 80 GB / 1000 GB)'] = store['Dedicado #1 (Celeron 2.0 / 1 GB / 2 x 80 GB / 1000 GB)'];
store['Dedicado #3 (P4 3.06 / 1 GB / 2 x 120 GB / 1000 GB)'] = store['Dedicado #1 (Celeron 2.0 / 1 GB / 2 x 80 GB / 1000 GB)'];
store['Dedicado #4 (Dual Xeon 2.0 / 1 GB / 2 x 73 GB SCSI / 1000 GB)'] = store['Dedicado #1 (Celeron 2.0 / 1 GB / 2 x 80 GB / 1000 GB)'];
store['Dedicado #5 (Dual Xeon 2.4 / 2 GB / 2 x 73 GB SCSI / 1000 GB)'] = store['Dedicado #1 (Celeron 2.0 / 1 GB / 2 x 80 GB / 1000 GB)'];

function init()
{
	optionTest = true;
	lgth = document.getElementById("plataforma").options.length ;
	document.getElementById("plataforma").options[lgth] = null;
	if (document.getElementById("plataforma").options[lgth]) optionTest = false;
}


function populate()
{
	if (!optionTest) return;
	var box = document.getElementById("planos");
	var number = box.options[box.selectedIndex].value;
	if (!number) return;
	var list = store[number];
	var box2 = document.getElementById("plataforma");
	box2.options.length = 0;
	for(i=0;i<list.length;i+=2)
	{
		box2.options[i/2] = new Option(list[i],list[i+1]);
	}
}


function writedept() {
	var vmail = document.forms[1].departamento.options[document.forms[1].departamento.selectedIndex].value;
    document.getElementById("txtdep").innerHTML = "<a href='mailto:" + vmail + "'><h3>" + vmail + "</h3></a>";
}
function FormataCampo(Campo,teclapres,mascara){
//pegando o tamanho do texto da caixa de texto com delay de -1 no event
//ou seja o caractere que foi digitado não será contado.
strtext = Campo.value
tamtext = strtext.length
//pegando o tamanho da mascara
tammask = mascara.length
//criando um array para guardar cada caractere da máscara
arrmask = new Array(tammask)
//jogando os caracteres para o vetor
for (var i = 0; i < tammask; i++){
 arrmask[i] = mascara.slice(i,i+1)
}
//alert (teclapres.keyCode)
//começando o trabalho sujo
if (((((arrmask[tamtext] == "#") || (arrmask[tamtext] == "9"))) || (((arrmask[tamtext+1] != "#") || (arrmask[tamtext+1] != "9"))))){
 if ((teclapres.keyCode >= 37 && teclapres.keyCode <= 40)||(teclapres.keyCode >= 48 && teclapres.keyCode <= 57)||(teclapres.keyCode >= 96 && teclapres.keyCode <= 105)||(teclapres.keyCode == 8)||(teclapres.keyCode == 9) ||(teclapres.keyCode == 46) ||(teclapres.keyCode == 13)){
  Organiza_Casa(Campo,arrmask[tamtext],teclapres.keyCode,strtext)
 } else {
  ExecFunc(Campo,strtext)
 }
} else {//Aqui funcionaria a mascara para números mas eu ainda não implementei
 if ((arrmask[tamtext] == "A")) {
  charupper = event.valueOf()
  //charupper = charupper.toUpperCase()
  ExecFunc(Campo,strtext)
  masktext = strtext + charupper
  Campo.value = masktext
 }
}
}

function Organiza_Casa(Campo,arrpos,teclapres_key,strtext){
if (((arrpos == "/") || (arrpos == ".") || (arrpos == "(") || (arrpos == ")") || (arrpos == ",") || (arrpos == ":") || (arrpos == " ") || (arrpos == "-")) && !(teclapres_key == 8)){

 if (arrpos == ")") {
 separador = arrpos + " "
 } else {
 separador = arrpos
 }

 masktext = strtext + separador
 Campo.value = masktext
}
}

function ExecFunc(Campo,strtext){
event.returnValue = false
if (strtext != "") {
 Campo.value = strtext
}
}

function valida() {
	if ((document.getElementById("planos").value == null) || (document.getElementById("planos").value == "")) {
		alert("Selecione um plano!");return false;
	}
	if ((document.getElementById("plataforma").value == null) || (document.getElementById("plataforma").value == "")) {
		alert("Selecione uma plataforma!");return false;
	}

	
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' deve ser preenchido corretamente.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' é obrigatório.\n'; }
  } if (errors) alert('Ocorreu o seguinte erro:\n'+errors);
  document.MM_returnValue = (errors == '');
}

//------------------------------

//------------------------------
