// JavaScript Document
function switchview() {
	
	//hide site content.
	document.getElementById('container').style.display = 'none';
	
	//change some styles.
	document.body.style.background = 'white';
	
	//change page title.
	document.title = 'Google';
	
	//load the page info an iframe. 
	document.getElementById('switchviewpage').innerHTML = '<iframe frameborder="0" height="100%" marginheight="0" marginwidth="0" scrolling="no" src="http://www.google.com/" width="100%"></iframe>';
		
}





//handle font size change.
var curFontSize; 	
var fontModifier = 0.2;

function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) {
	    endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
}

function FixCookieDate(date) {
	var base = new Date(0);
	var skew = base.getTime();
	if (skew > 0)  {
		date.setTime (date.getTime() - skew);
	}
}

function GetCookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i=0;
	while (i < clen) {	
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) {
		    return getCookieVal (j);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i === 0) {
		    break;
		}
	}
	return null;
}

function SetCookie(name,value,expires,path,domain,secure) {
	document.cookie = name + "=" + escape (value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}

function fontSize(act) {
    if (document.getElementById("content")) {
        storyBody = document.getElementById("content");
        if (act === 1) {
            curFontSize += fontModifier;
            curFontSize = Math.min(curFontSize, 2);
        } else if (act === 0) {
            curFontSize -= fontModifier;
            curFontSize = Math.max(curFontSize, 1);
        }
        storyBody.style.fontSize = curFontSize + "em";
		

    }
	
	// set cookie with font size
	var expdate = new Date();
	FixCookieDate (expdate);
	expdate.setTime (expdate.getTime() + (672*60*60*1000)); // 4 weeks
	
	SetCookie("userfontc",curFontSize,expdate);		

//return(false);
}


	
	


	function windowOpen(url, w, h) {
		window.open(url,'','width='+w+',height='+h+',left=30,top=30');
	}


var SOSquizArray = new Array();
SOSquizArray[0] = "2";
SOSquizArray[1] = "1,2";
SOSquizArray[2] = "0,1";
SOSquizArray[3] = "1,2";
SOSquizArray[4] = "0,1";
SOSquizArray[5] = "1,2";
SOSquizArray[6] = "1,2";
SOSquizArray[7] = "0,1";
SOSquizArray[8] = "1,2";
function validate_answer(quest,ans) {
	if (SOSquizArray[quest].indexOf(ans) != -1) {
		document["alert" + quest].src = "images/alert.gif";
	}
	else {
		document["alert" + quest].src = "images/space.gif";
	}
}

	
window.onload = function() {
	
	if (isNaN(parseFloat(GetCookie("userfontc")))) {
		curFontSize = 1;
		
	} else {
		curFontSize = parseFloat(GetCookie("userfontc"));
		if(curFontSize == undefined) curFontSize = 1;
		
	}
	//GetCookie("userfontc");
	
	var storyBody = '';
	if (document.getElementById("content")) {
		storyBody = document.getElementById("content");
		storyBody.style.fontSize = curFontSize + "em";
	}
		
	//get page filename
	var tr = window.location.pathname;
	var url = '';
	var len = tr.length;
	var rs = 0;
	var vb = '';
	for (var i = len; i > 0; i--) {
		vb = tr.substring(i,i+1)
		if (vb == "/" && rs == 0) {
			url = tr.substring(i+1,len).toLowerCase();
			rs = 1
		}
	} 
	
	
	if (url == 'services.htm') {
		windowOpen('popup.htm', 260, 233);
	}
	if (url == 'friend.htm') {
		windowOpen('popup.htm', 260, 233);
	}
}

