﻿//BEGIN scripturi pt. schimbare font portal pe partea publica
var min=8;
var max=16;
var reset=12;
function increaseFontSize() {
   var p = document.getElementsByTagName('div');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('div');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}
function resetFontSize() {
   var p = document.getElementsByTagName('div');
   for(i=0;i<p.length;i++) {
      p[i].style.fontSize = reset+"px"
   }   
}
//END scripturi pt. schimbare font portal pe partea publica

//BEGIN scripturi admin
var arrowRight = new Image();
arrowRight.src="img/arrowRight.gif";

var arrowDown = new Image();
arrowDown.src= "img/arrowDown.gif";

function ref(instance_or_id)
{
    return(typeof(instance_or_id)=="string")?document.getElementById(instance_or_id):instance_or_id;
}

function expandCollapse(divId, arrowId)
{
    var arrow = ref(arrowId);

    if (arrow) arrow.src = (toggleDisplay(divId)) ? "img/arrowDown.gif" : "img/arrowRight.gif";
    else alert(arrowId + " does not exist");
}

function toggleDisplay(divId)
{
    var tempDiv = ref(divId);
    //alert(tempDiv.style.display);
    if(!tempDiv) return false;
    if(tempDiv.style.display=="block" || tempDiv.style.display=="")
    {
        tempDiv.style.display="none";
        return false;
    }
    else if(tempDiv.style.display=="none")
    {
        tempDiv.style.display="block";
        return true;
    }
}

function objDisplay(obj, tbx1, tbx2)
{
    
    var object = document.getElementById(obj);
    var tbxPass = document.getElementById(tbx1);
    var tbxConfPass = document.getElementById(tbx2);
    
    if(object.checked)
    {        
        tbxPass.disabled = false;
        tbxConfPass.disabled = false;
        
    }
    else
    {        
        tbxPass.disabled = true;
        tbxConfPass.disabled = true;
        
    }
}

function objDisplayNone(obj, tbx1, tbx2) {

    var object = document.getElementById(obj);
    var tbxPass = document.getElementById(tbx1);
    var tbxConfPass = document.getElementById(tbx2);

    if (object.checked) {
        tbxPass.disabled = true;
        tbxConfPass.disabled = true;

    }
    else {
        tbxPass.disabled = false;
        tbxConfPass.disabled = false;

    }
}




function tbxDisplay(ckb, obj) 
{
    var objectCkb = document.getElementById(ckb);
    var objectObj = document.getElementById(obj);

    if (objectCkb.checked) 
    {
        objectObj.disabled = false;
    }
    else 
    {
        objectObj.disabled = true;
    }
}

function objDisplayHide(obj) {
    var objectObj = document.getElementById(obj);

    if (objectObj.style.display == "none") {
        objectObj.style.display = "block";
    }
    else {
        objectObj.style.display = "none";
    }
}

function objDisplay(obj) {
    var objectObj = document.getElementById(obj);
    objectObj.style.display = "block";

}

function objHide(obj) 
{
        var objectObj = document.getElementById(obj);
        objectObj.style.display = "none";
}

function TestFloat(e, textboxId) {
    
    var k;
    var num='1234567890.'
    k = document.all ? parseInt(e.keyCode) : parseInt(e.which);
    //alert(k);
    var txtContent = document.getElementById(textboxId);
    if(k==0 || k==8)
    return true;


    if(k==46)
    {
    if(txtContent.value.lastIndexOf(String.fromCharCode(k))>0)
    return false;
    }
    return (num.indexOf(String.fromCharCode(k))!=-1);
}

//END scripturi admin


//send mail
function SendEmail(name, domain, extension, subject){
    window.location = 'mailto:' + name + '@' + domain + '.' + extension + '?subject=' + subject;
    //mailto:recipient1@yourmail.com;recipient2@yourmail.com?subject=SUBJECT LINE GOES HERE &cc=recipient3@yourmail.com&bcc=recipient4@yourmail.com&body=BODY MESSAGE GOES HERE"
}


function redirectIfPublic(url) {
    if (document.location.toString().toUpperCase().indexOf('/ADMIN') == -1) {
        document.location = url;
    } else {
        alert('Redirect: ' + url);
    }
}
