// text resizing
var currentTextSize = null;
var currentLineHeight = null;
// check for cookie
if (get_text_cookie("btfontsize")) {
    currentTextSize = parseInt(get_text_cookie("btfontsize"));
} else {
    currentTextSize = 13;
    createCookie("btfontsize",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('box_artikle').style.fontSize = currentTextSize + 'px';
    //document.getElementById('box_artikle').style.lineHeight = currentLineHeight + 'px';


    var allHTMLTags = new Array();
    //Create Array of All HTML Tags
    var allHTMLTags=document.getElementsByTagName("*");
    //Loop through all tags using a for loop
    for (i=0; i<allHTMLTags.length; i++) {
        //Get all tags with the specified class name.
        
        if (allHTMLTags[i].className == "articol") {
            var allPTags=allHTMLTags[i].getElementsByTagName("p");
            for (j=0; j<allPTags.length; j++) {    
                allPTags[j].style.fontSize = currentTextSize + 'px';
            }
        }
    }
    //setStyleByClass("p", "articol", "fontSize",currentTextSize + 'px');
    //ChangeCSSRule('color',this.value)
    //document.getElementById('commenttext').style.fontSize = currentTextSize + 'px';
    //document.getElementById('commenttext').style.lineHeight = currentLineHeight + 'px';
    // write/rewrite cookie
    createCookie("btfontsize",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 ChangeCSSRule(xElement,xValue) {  
         var strCSS = 'cssRules';  
 if(document.all) {  
            strCSS = 'rules';  
         }  
         document.styleSheets[0][strCSS][0].style[xElement] = xValue;  
 }
