var blink = "true";
var normalColor = "white";

function newsStartup(timestamp) {
	if(!(fetch_cookie("minimized"))) {
		set_cookie("minimized","0");
		set_cookie("timestamp",timestamp,"");
	}

	if(fetch_cookie("minimized") == "1") {
		document.getElementById("newstable").style.display = "none";
		document.getElementById("navbarnews").style.display = "table-cell";
	}

	if(fetch_cookie("minimized") == "1" && fetch_cookie("timestamp") < timestamp ) {
		set_cookie("timestamp",timestamp);
		blinkNotify();
	}

	if(fetch_cookie("minimized") == "0" && fetch_cookie("timestamp") != timestamp ) {
		set_cookie("timestamp",timestamp);
	}
}

function minimizeNewstab() {
	set_cookie("minimized","1");
	document.getElementById("newstable").style.display = "none";
	document.getElementById("navbarnews").style.display = "table-cell";
	blink ="true";
	blinkNotify();
}

function maximizeNewstab() {
	set_cookie("minimized","0");
	document.getElementById("newstable").style.display = "block";
	document.getElementById("navbarnews").style.display = "none";
}

function blinkNotify() {
	if(blink == "true") {
		document.getElementById("navbar_news").style["color"] = "red";
		window.setTimeout("blinkNotify2()",500);
	} else {
		document.getElementById("navbar_news").style["color"] = normalColor;	
	}
}

function blinkNotify2() {
	if(blink == "true") {
		document.getElementById("navbar_news").style["color"] = "black";
		window.setTimeout("blinkNotify()",500);
	} else {
		document.getElementById("navbar_news").style["color"] = normalColor;	
	}
}

function stopNotify() {
	blink ="false";
}

function setNormalColor(color) {
	if(color == "#FFFFFF") {
		normalColor = "white";
	}
	if(color == "#000000") {
		normalColor = "black";
	}
	if(color == "#000") {
		normalColor = "black";
	}
	if(color == "black") {
		normalColor = "black";
	}
}

//AJAX Functions for Link Counter

var req = false;
function linkCount(url) {
   req = false;
   if(window.XMLHttpRequest) {
      try {
         req = new XMLHttpRequest();
      } catch(e) {
         req = false;
      }
   } else if(window.ActiveXObject) {
      try {
         req = new ActiveXObject("Msxml2.XMLHTTP");
      } catch(e) {
         try {
            req = new ActiveXObject("Microsoft.XMLHTTP");
         } catch(e) {
            req = false;
         }
      }
   }
   if(req) {
      req.onreadystatechange = processReqChange;
      req.open("GET", url, true);
      req.send(null);
   }
}

function processReqChange() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            // I don't wanna do anything
        } else {
		// The User doesn't need to know about the error
        }
    }
}