﻿function changeFontSize(arg){
var title, y;
var title = getActiveFont();
//alert(title);
var x = title.split("fontSize")[1];
var direction = arg.split("fontSize")[1];
if(direction == "Up"){
if(x >= 3){
x = 2;
}
y = "fontSize" + (parseInt(x) + 1);
}

if(direction == "Down"){
if(x < 1){
x = 1;
}
else{
y = "fontSize" + (parseInt(x) - 1);
}
}
setActiveStyleSheet(y);
}

function getActiveFont(){
var tags = document.getElementsByTagName("link");
var i, a, title;
for(i = 0; i < tags.length; i++){
a = tags[i];
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && a.getAttribute("title").indexOf("fontSize") != -1 && !a.disabled){
return a.getAttribute("title");
}
}
}


function setActiveStyleSheet(title){
var tags = document.getElementsByTagName("link");
var type, i, a;
for(i = 0; i < tags.length; i++){
a = tags[i];
if(title){
if(title.indexOf("fontSize") != -1){
type = "font";
}
if(title.indexOf("toggle") != -1){
type = "toggle";
}
if(type == "toggle"){
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && a.getAttribute("title").indexOf("toggle") != -1){
a.disabled = true;
if(a.getAttribute("title") == title){
a.disabled = false;
}
}
}

if(type == "font"){
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && a.getAttribute("title").indexOf("fontSize") != -1){
a.disabled = true;
if(a.getAttribute("title") == title){
a.disabled = false;
}
}
}

}
}

}
