ord=Math.random()*10000000000000000;

function Get_Cookie(name) {
	var start = document.cookie.indexOf(name + "=");
	var len = start + name.length + 1;

	if((!start) && (name != document.cookie.substring(0, name.length)))
	{

		return null;

	}

	if(start == -1 ) return null;

	var end = document.cookie.indexOf(";", len);
	if ( end == -1 ) end = document.cookie.length;

	return unescape( document.cookie.substring( len, end ) );
}


function getInfo(index){

	var usr = Get_Cookie('auth')

	if(usr != null){

		var result = usr.split("|");
		return result[index];

	}else{

		return null;

	}

}

function isMember(){

	var usr = Get_Cookie('auth')

	if(usr != null){

		return 'y';

	}else{

		return 'n';


	}


}

function isLoggedIn(cookie_name){
	//var usr = Get_Cookie('auth')
	var usr = Get_Cookie(cookie_name)

	if(usr != null){
/*
		var acctStatus = getInfo(8);

		if( acctStatus != 0 ) {
			return true;
		} else {
			return false;
		}
*/

		//No need to check for account activation status... as the login form controller will redirect user to '/grActivateUser.htj' in the
		//event account has not yet been activated.  Thus, at this point, account will have been activated and therefore, detection of cookie
		//is enough to login the user
		return true;
	}else{

		return false;


	}
}

function isUnderageCookieFound() {
	var nameEQ = 'grRegistration' + "=";
	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 getGen(){

	var gen = getInfo(7);

	if(gen != null){

		return gen.toLowerCase();

	}else{

		return null;

	}

}

function getUsername(){

	var userName = getInfo(1);

	if(userName == null){

	  userName = "";

	}
	return userName;

}

function getAgeGroup(){

	var age = getInfo(22);

	if (age != null){

		if(age < 18){

			return 1;

		}else if(age >= 18 && age <= 24){

			return 2;

		}else if(age >= 25 && age <= 30){

			return 3;

		}else if(age >= 31 && age <= 35){

			return 4;

		}else if(age >= 36 && age <= 40){

			return 5;

		}else{

			return 6;

		}

	}else{

		return null;

	}


}



var newWin = null;
function popUp(strURL, strType, strHeight, strWidth) {
 if (newWin != null && !newWin.closed)
   newWin.close();
 var strOptions="";
 if (strType=="console")
   strOptions="resizable,height="+
     strHeight+",width="+strWidth;
 if (strType=="fixed")
   strOptions="status,height="+
     strHeight+",width="+strWidth;
 if (strType=="elastic")
   strOptions="toolbar,menubar,scrollbars,"+
     "resizable,location,height="+
     strHeight+",width="+strWidth;
 newWin = window.open(strURL, 'newWin', strOptions);
 newWin.focus();
}

function setWSPSession(platform){

	setSession("wsp", platform);

}

function getWSPSession(platform){

	return getSession("wsp", platform);

}

function setISTSession(platform){

	setSession("ist", platform);

}

function getISTSession(platform){

	return getSession("ist", platform);

}

var text_ad_width;
var text_ad_height;

function google_ad_request_done(google_ads) {
 /*
  * This function is required and is used to display
  * the ads that are returned from the JavaScript
  * request. You should modify the document.write
  * commands so that the HTML they write out fits
  * with your desired ad layout.
  */
 var s = '';
 var i;

 /*
  * Verify that there are actually ads to display.
  */
 if (google_ads.length == 0) {
	return;
 }

 /*
  * If an image or Flash ad is returned, display that ad.
  * Otherwise, build a string containing all of the ads and
  * then use a document.write() command to print that string.
  */
 s += '<div align="center">';

 if (google_ads[0].type == "flash") {

	s += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
        ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"' +
        ' WIDTH="' + google_ad.image_width +
        '" HEIGHT="' + google_ad.image_height + '">' +
        '<PARAM NAME="movie" VALUE="' + google_ad.image_url + '">'
        '<PARAM NAME="quality" VALUE="high">'
        '<PARAM NAME="AllowScriptAccess" VALUE="never">'
        '<EMBED src="' + google_ad.image_url +
        '" WIDTH="' + google_ad.image_width +
        '" HEIGHT="' + google_ad.image_height +
        '" TYPE="application/x-shockwave-flash"' +
        ' AllowScriptAccess="never" ' +
        ' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';

 } else if (google_ads[0].type == "image") {

	s += '<a href="' + google_ads[0].url +
        '" target="_top" title="go to ' + google_ads[0].visible_url +
        '"><img border="0" src="' + google_ads[0].image_url +
        '"width="' + google_ads[0].image_width +
        '"height="' + google_ads[0].image_height + '"></a>';

 } else {


   s += '<table align="center" bgcolor="#FFFFFF" width="' + text_ad_width + '" height="' + text_ad_height + '" border="0" cellspacing="0" cellpadding="0" style="border:solid 1px #FFCC00;width:' + text_ad_width + 'px;height:' + text_ad_height + 'px">';

	if (google_ads.length == 1) {
	  s += '<tr valign="top">';
	  s += '<td style="padding:3px 3px 3px 3px"><a href="' + google_ads[0].url + '" ' +
          'onmouseout="window.status=\'\'" ' +
          'onmouseover="window.status=\'go to ' +
          google_ads[0].visible_url + '\'" ' +
          'style="text-decoration:none">' +
          '<span style="text-decoration:underline;font-size:20pt">' +
          '<b>' + google_ads[0].line1 + '</b><br></span>' +
          '<span style="color:#000000;font-size:16pt">' +
          google_ads[0].line2 + '&nbsp;' +
          google_ads[0].line3 + '<br></span>' +
          '<span style="color:#008000;font-size:14pt">' +
          google_ads[0].visible_url + '</span></a></td>';
		  s += '</tr>';

	} else if (google_ads.length > 1) {

	  var cell_width = 100 / google_ads.length;

	  if(text_ad_width > text_ad_height * 2){

	  	 s += '<tr valign="top">';

	  }

	  for(i=0; i < google_ads.length; ++i) {

		 if(text_ad_width < text_ad_height * 2){

	  	 s += '<tr valign="top">';

	  	 }
		 s += '<td style="padding:3px 3px 3px 3px"><a href="' + google_ads[i].url + '" ' +
            'onmouseout="window.status=\'\'" ' +
            'onmouseover="window.status=\'go to ' +
            google_ads[i].visible_url + '\'" ' +
            'style="text-decoration:none">' +
            '<span style="text-decoration:underline">' +
            '<b>' + google_ads[i].line1 + '</b><br></span>' +
            '<span style="color:#000000">' +
            google_ads[i].line2 + '<br>' +
            google_ads[i].line3 + '<br></span>' +
            '<span style="color:#008000">' +
            google_ads[i].visible_url + '</span></a></td>';

		if(text_ad_width < text_ad_height * 2){

			s += '</tr>';

		}

	  }

	  if(text_ad_width > text_ad_height * 2){

			s += '</tr>';

		}
	}


   s += '<tr><td colspan="' + google_ads.length + '" style="color:black;text-align:left;font-size:11px;padding:1px 1px 1px 3px">Ads by Google</td></tr>';
	s += '</table>';

 }

 s += '</div>';
 document.write(s);
 return;
}



