//newsletter
function newsletter_on(id) {
  if (document.getElementById(id).value=="Adresa ta de E-mail") document.getElementById(id).value="";
  };
function newsletter_off(id) {
  if (document.getElementById(id).value=="") document.getElementById(id).value="Adresa ta de E-mail";
  };

//login
function user_on(id) {
  if (document.getElementById(id).value=="username") document.getElementById(id).value="";
  };
function user_off(id) {
  if (document.getElementById(id).value=="") document.getElementById(id).value="username";
  };
function pass_on(id) {
  if (document.getElementById(id).value=="parola") document.getElementById(id).value="";
  };
function pass_off(id) {
  if (document.getElementById(id).value=="") document.getElementById(id).value="parola";
  };

//comanda
function show(id) {
  document.getElementById(id).style.display="block";
  };

function hide(id) {
  document.getElementById(id).style.display="none";
  };

function pf() {
  hide('factura');
  hide('pj_plata');
  hide('pj_content');
  //hide('pf_content_cash');
  //hide('pf_content_posta_romana');
  //hide('pf_content_western_union');
  //hide('pf_content_transfer_bancar');
  show('pf_plata');
  show('pf_content');
  };

function pj() {
  hide('pf_plata');
  hide('pf_content');
  //hide('pj_content_cash');
  //hide('pj_content_posta_romana');
  //hide('pj_content_western_union');
  //hide('pj_content_op');
  show('factura');
  show('pj_plata');
  show('pj_content');
  };

function show_content(contentType, contentNo) {
  for (i=1; i<=4; i++) {
    document.getElementById(contentType+"_content_"+i).style.display="none";
    }
  document.getElementById(contentType+"_content_"+contentNo).style.display="block";
  };

//cautare
function cauta_on(id) {
  if (document.getElementById(id).value=="cauta ziar...") document.getElementById(id).value="";
  };
function cauta_off(id) {
  if (document.getElementById(id).value=="") document.getElementById(id).value="cauta ziar...";
  };

function showhide(div_id) {
  if (document.getElementById(div_id).style.display=="none") {
    document.getElementById(div_id).style.display="block";
    }
  else {
    document.getElementById(div_id).style.display="none";
    }
  };

//adaugare ziar
var def=new Array();

def["nume_ziar"] = "ex: Evenimentul Zilei";
def["periodicitate"] = "ex: cotidian luni-vineri/ saptamanal - joi";
def["dimX"] = "34";
def["dimY"] = "55";
def["nr_pagini"] = "ex: 20 pagini din care Policromie 8 pagini";
def["supliment"] = "ex: Supliment TV - Vineri";
def["tiraj"] = "ex: 12.000 de exemplare";
def["pers_contact"] = "ex: Director Publicitate - Dumitru Cristian";
def["telefon"] = "ex: 0256 010 010";
def["fax"] = "ex: 0256 010 010";
def["mobil"] = "ex: 0728 011 011";
def["email"] = "ex: contact@publicitateziare.eu";
def["of_speciala"] = "ATENTIE! Oferta Speciala va aparea pe prima pagina a siteului si in pagina cu oferte speciale.";

function saveValue(element) {
  if (element.value == def[element.name]) {
    element.value = "";
    }
  };

function pasteValue(element) {
  if (element.value == "") {
    if (element.name == "of_speciala") {}
    else if (element.name == "fax") {}
    else if (element.name == "supliment") {}
    else if (element.name == "mobil") {}
    else {
      element.value = def[element.name];
      }
    }
  };

function goto(page) {
  window.location = page;
  }


// caractere ramase
function limit_chars_title(MyTitleBox) {
  if (MyTitleBox.value.length > 40) {
    MyTitleBox.value = MyTitleBox.value.substring(0, 40);
    }
  else {
    if (MyTitleBox.value.length < 5) {
      document.getElementById("title_count_area").innerHTML="<font color='red'>Caractere: " + MyTitleBox.value.length + "/40</font>";
      }
    else {
      document.getElementById("title_count_area").innerHTML="<font color='green'>Caractere: " + MyTitleBox.value.length + "/40</font>";
      }
    }
  }

var MyLastText = "";
function limit_chars_textarea(MyTextBox) {
  if (MyTextBox.value.length > 1000) {
    MyTextBox.value = MyTextBox.value.substring(0, 1000);
    }
  else {
    if (MyTextBox.value.length < 100) {
      document.getElementById("textarea_count_area").innerHTML="<font color='red'>Caractere: " + MyTextBox.value.length + "/1000</font>";
      }
    else {
      document.getElementById("textarea_count_area").innerHTML="<font color='green'>Caractere: " + MyTextBox.value.length + "/1000</font>";
      }
    }
  var MyWords = MyTextBox.value.split(" ");
  var Fail = 0;
  for (i=0; i<MyWords.length; i++) {
    if (MyWords[i].length > 29) {
      Fail = Fail + 1;
      }
    }
  if (Fail > 0) {
    MyTextBox.value = MyLastText;
    }
  MyLastText=MyTextBox.value;
  }

// setare width anunturi pentru reclama din dreapta - anunturi pe judete
function set_width_to_adds(addNo) {
  for (i=1; i<=addNo; i++) {
    MyAdd=document.getElementById("anunt_" + i);
    if (MyAdd.offsetTop < 600) {
      MyAdd.style.width = 550 + "px";
      }
    }
  }
