/**
 * Constants
 */
/**
 * Used to show/hide some divs based on a value from a dropdown
 */ 
function doShowHideReceive(el, dbId){
      var val = $(el).val();
			switch(parseInt(val)){
			case 1:
				$("#te_" + dbId).hide();
				$("#tt_" + dbId).show();
				
				$("#nmail_" + dbId).hide();
				$("#ntel_" + dbId).show();
				$("#opt3_" + dbId).hide();
				break;
			case 3:
				$("#te_" + dbId).hide();
				$("#tt_" + dbId).show();
				
				$("#nmail_" + dbId).hide();
				$("#ntel_" + dbId).show();
				$("#opt3_" + dbId).show();
				break;
			case 4:
				$("#te_" + dbId).show();
				$("#tt_" + dbId).hide();
				
				$("#nmail_" + dbId).show();
				$("#ntel_" + dbId).hide();
				$("#opt3_" + dbId).hide();
				break;
			}
}

function doFoto(kid, num, cdrid){
    var action = "tf5.asp?id=" + kid + "&num=" + num + "&cdrid=" + cdrid;
    var myWindow = window.open(action,'myfotowindow','width=600,height=600,toolbar=no, location=yes,directories=no,status=yes,menubar=no,scrollbars=no,copyhistory=yes,resizable=yes'); 
		if (!myWindow.opener) myWindow.opener = self;
    return false;
}

function showHoraFrame(){
	//Get the screen height and width
	var maskWidth = screen.availWidth;
	var maskHeight = screen.availHeight;
	
	//maskHeight = $(window).height();

	var mask = document.getElementById("mask");
    //Set heigth and width to mask to fill up the whole screen
	mask.style.width = maskWidth + "px";
	mask.style.height = maskHeight + "px";
	mask.style.display = "block";
	
	var scrollTop = $(window).scrollTop();

  $("#mask").css('top', scrollTop + "px");
	//mask.style.opacity = "0.8";
    
    //Set the popup window to center
    $("#d_horaframe").css('top', (scrollTop + 100) + "px");
    $("#d_horaframe").css('left', 100 + "px");

  $("#d_horaframe").show();
  
  $("#d_horaframe").draggable({ handle: 'header' });
  
  return true;
}

function hideHoraFrame(flag){
  if (flag){
    window.location.href=window.location.href;
  }
  $("#d_horaframe").hide();
  $("#mask").hide();
}



function toogleText(el){
  if (el.checked){
    $("#text2hide").show();
  } else {
    $("#text2hide").hide();
  }
}

function toogleRows(el, isMain){
var srcPlus = "image_mais_pq.jpg";
var srcMinus = "image_menos_pq.jpg";

  var src = $.attr(el, "src");
  var show = false;
    if (src.indexOf(srcMinus) != -1){
    $.attr(el, "src", srcPlus);
    show = false;
  } else {
    $.attr(el, "src", srcMinus);
    show = true;
  }

  while(el != undefined && el.tagName != "TR") { el = el.parentNode; }
  var rowEl = el;
  while(el != undefined && el.tagName != "TABLE") { el = el.parentNode; }
  var tableEl = el;
  var rows = tableEl.rows;
  var i = rowEl.rowIndex + 1;
//  while (i<rows.length){
//    if ($(rows[i]) != $(rowEl)) i++; else break;
//  }

  var blockEnd = "END_BLOCK2";
  if (isMain != undefined){
    blockEnd = "END_BLOCK1";
  }

    while ( i < rows.length ){
      if (rows[i].id != blockEnd) {
        if (show) $(rows[i]).show(); else $(rows[i]).hide();
        i++;
      } else break;
  }

}

function openSearchWnd(){
  window.open("http://www.google.com");
}

$(document).ready(function() {
/*     $("#mask").click(function() {
        hideHoraFrame();
    });*/
    
  

});
