// text resizing
var currentTextSize = null;
var currentLineHeight = null;
// check for cookie
if (get_text_cookie("pandurulfontsize")) {
    currentTextSize = parseInt(get_text_cookie("pandurulfontsize"));
} else {
    currentTextSize = 13;
    createCookie("pandurulfontsize",currentTextSize,1000);
}
currentLineHeight = currentTextSize + 5;

function textSize(dir) {
    if (dir == 'up') {
        if (currentTextSize <= 16) {
            currentTextSize += 1;
        }
    } else if (dir == 'down') {
        if (currentTextSize >= 12) {
            currentTextSize -= 1;
        }
    }
    currentLineHeight = currentTextSize + 5;
    document.getElementById('corpArticol').style.fontSize = currentTextSize + 'px';
    document.getElementById('corpArticol').style.lineHeight = currentLineHeight + 'px';
    document.getElementById('comentariiArticol').style.fontSize = currentTextSize + 'px';
    document.getElementById('comentariiArticol').style.lineHeight = currentLineHeight + 'px';
    // write/rewrite cookie
    createCookie("pandurulfontsize",currentTextSize,1000);
}

function get_text_cookie ( cookie_name )
{
  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );

  if ( results ) {
    return ( unescape ( results[1] ) );
  }
  else { return null; }
}

// creates a cookie with the given parameters
function createCookie(name,value,days){
	if (days){
		var date = new Date();
		date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		var expires = "; expires=" + date.toGMTString();
	} else {
		var expires = "";
	}
	document.cookie = name + "=" + value + expires + "; path=/";
}

function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) 
		field.value = field.value.substring(0, maxlimit);
	else
		cntfield.value = maxlimit - field.value.length;
}

function showPic (whichpic) {
 if (document.getElementById) {
  document.getElementById('placeholder')
  .src = whichpic.href;
  document.getElementById('placeholder')
  .title = whichpic.title;
  document.getElementById('placeholder')
  .alt = whichpic.alt;
  document.getElementById('holderlink')
  .title = whichpic.title;
  document.getElementById('holderlink')
  .href = whichpic.href.replace("mare","maxim");;
  if (whichpic.title) {
   document.getElementById('descCaption')
  .childNodes[0].nodeValue = whichpic.title;
  } else {
   document.getElementById('descCaption')
  .childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue;
  }
  return false;
 } else {
  return true;
 }
}