// JavaScript Document

function GetRandomCSS() {
	(document.cookie.indexOf("acneGender")!=-1)?
      cookieEnabled=true:cookieEnabled=false;
   if(cookieEnabled) {
      return GetCookie("acneGender");
   }
   
   var cssList = new Array(
        'css/homePageFemale.css',
        'css/homePageMale.css');
   var randnum = Math.floor(cssList.length *
        Math.random());
   setCookie("acneGender", cssList[randnum]);
   return cssList[randnum];
}

function changeCSS() {
   document.getElementById('cssHolder').setAttribute(
        'href',
        GetRandomCSS());
}

function setFCookie(){
	setCookie("acneGender", escape('css/homepageFemale.css'));	
}

function setMCookie(){
	setCookie("acneGender", escape('css/homepageMale.css'));
}

function setCookie(name, value) {
	var theCookie= name + "=";
	theCookie = theCookie + escape(value);
	document.cookie = theCookie;
}

function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) { endstr = document.cookie.length; }
	return unescape(document.cookie.substring(offset,endstr));	
}

function GetCookie(name) {
	var arg = name + "=";
	var argLength = arg.length;
	var cookieLength = document.cookie.length;
	var i = 0;
	while (i < cookieLength) {
		var j = i + argLength;
		if (document.cookie.substring(i,j) == arg) {
			return getCookieVal(j);	
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}
