// JavaScript Document

var currentEl = null;
var currentSize = 1;

function setFontSize(size, el)
{
    clearOnClass();
    document.getElementById(el).className='on'   
	if ( document.body )
	{
		document.body.style.fontSize = size + 'em';
	}	
	 createCookie("font_size", size, "30");
}

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 readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];		
		while (c.charAt(0)==' ') c = c.substring(1,c.length); 
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}

function loadFontSize ()
{ 
	if (readCookie('font_size') == null) {
		currentSize = 1;
	} else {
		currentSize = readCookie('font_size');
	}
	
	if (currentSize == '1'){currentEl = 'smallTxt'}
	if (currentSize == '1.15'){currentEl = 'medTxt'}
	if (currentSize == '1.25'){currentEl = 'lrgTxt'}
	setFontSize (currentSize, currentEl);
}

function clearOnClass()
{
     document.getElementById('smallTxt').className='';
     document.getElementById('medTxt').className='';
     document.getElementById('lrgTxt').className='';
 }


 function getCookie(c_name) {
     if (document.cookie.length > 0) {
         c_start = document.cookie.indexOf(c_name + "=");
         if (c_start != -1) {
             c_start = c_start + c_name.length + 1;
             c_end = document.cookie.indexOf(";", c_start);
             if (c_end == -1) c_end = document.cookie.length;
             return unescape(document.cookie.substring(c_start, c_end));
         }
     }
     return "";
 }

 function setCookie(c_name, value, expiredays, path) {
     var exdate = new Date();
     exdate.setDate(exdate.getDate() + expiredays);
     document.cookie = c_name + "=" + escape(value) +
            ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString()) +
    ((path) ? "; path=" + path : "");
 }

 function checkCookie() {
//     var a;
//     noOfClicks = getCookie('noOfClicks');
//     if (noOfClicks != null && noOfClicks != "") {
//         a = getCookie('noOfClicks');
//         a = parseInt(getCookie('noOfClicks')) + 1;
//         setCookie('noOfClicks', parseInt(getCookie('noOfClicks')) + 1, 1, '/');
//         if (a == 3) {
//             trackofClicks();
//         }
//     }
//     else {
//         setCookie('noOfClicks', 1, 1, '/');
//     }

 }

 function trackofClicks() {
//     username = getCookie('username');
//     if (username != null && username != "") {

//     }
//     else {
//         //setCookie('username', 'survey', 1);
//         //myFunction();
//     }
 }


 function popitup(url) {
     newwindow = window.open(url, 'name', 'height=800,width=420,scrollbars=1,toolbar=1,status=1');
     if (window.focus) { newwindow.focus() }
     return false;
 }

 function myFunction() {
//     setCookie('username', 'survey', 1, '/');
//     setTimeout(popitup('../../survey.aspx'), 120000);
 }
