

  // JAVASCRIPT TO CHECK FOR THE EXISTANCE OF A COOKIE 
  // Check if a user is logged in. Return HTML for navigation buttons based on login status

    // if login cookie exists and is not null
    if (document.cookie.indexOf("apc_userid=") == -1 ||
		document.cookie.charAt(document.cookie.indexOf("apc_userid=") + 10) == "" ||
      	document.cookie.charAt(document.cookie.indexOf("apc_userid=") + 10) == ";" ) {
	   	var cookieVal = 'false';
    } else {
		var cookieVal = 'true';
	}
  
	// login buttons


 var buttonHTML = '';
	var homeButton = '';
	var urlStr = window.document.location + '';
	var testMembers = /members(((\/(homepage|[0-9]|$))+)|$)/;
	var testPublic = /.com:*[0-9]*(((\/(homepage|[0-9]|$))+)|$)/;
		if (testMembers.test(urlStr) == true) {
			homeButton =  '<img src="/images/apcentral/but_home_on.gif" alt="Home: AP Central home page.">';
			var breadCrumbLink = '';
			var ads = '<a href="http://apcentral.collegeboard.com/article/0,,184-0-0-18248,00.html"><img src="/images/apcentral/ads/ap02_ban_westin_apnc_02.jpg" width="120" height="60" border="0"></a>'
			ads += '<br>'
			ads += '<br>'
			ads += '<a href="http://apps.apcentral.collegeboard.com/EventSearchParams.jsp"><img src="/images/apcentral/ads/approf120x60.gif" width="120" height="60" border="0"></a>'
			ads += '<br>'
			ads += '<br>'
			ads += '<a href="http://www.collegeboard.com/about/newsat/newsat.html" target="_blank"><img src="/images/apcentral/ads/newsat.gif" width="120" height="60" border="0"></a>'
			ads += '<br>'
			ads += '<br>'
			ads += '<a href="http://www.avidonline.org/info/?ID=383" target="_blank"><img src="/images/apcentral/ads/NC_AP_Button.gif" width="120" height="60" border="0"></a>'
		} else if (testPublic.test(urlStr) == true) {  
			homeButton =  '<img src="/images/apcentral/but_home_on.gif" alt="Home: AP Central home page.">';
			var breadCrumbLink = '';
			var ads = '<a href="http://apcentral.collegeboard.com/article/0,,184-0-0-18248,00.html"><img src="/images/apcentral/ads/ap02_ban_westin_apnc_02.jpg" width="120" height="60" border="0"></a>'
			ads += '<br>'
			ads += '<br>'
			ads += '<a href="http://apps.apcentral.collegeboard.com/EventSearchParams.jsp"><img src="/images/apcentral/ads/approf120x60.gif" width="120" height="60" border="0"></a>'
			ads += '<br>'
			ads += '<br>'
			ads += '<a href="http://www.collegeboard.com/about/newsat/newsat.html" target="_blank"><img src="/images/apcentral/ads/newsat.gif" width="120" height="60" border="0"></a>'
			ads += '<br>'
			ads += '<br>'
			ads += '<a href="http://www.avidonline.org/info/?ID=383" target="_blank"><img src="/images/apcentral/ads/NC_AP_Button.gif" width="120" height="60" border="0"></a>'
		} else {
			homeButton = '<a href="/members/1,3050,,00.html"><img src="/images/apcentral/but_home.gif" alt="Home: AP Central home page." width="66" height="30" border="0"></a>';
			var breadCrumbLink = '<a href="/members/1,3050,,00.html" class="arialEleven006699Bold">Home</a>'
			var ads = '';
		}
	 
	if (cookieVal == "true") {
		
		buttonHTML += '<td valign="bottom">' + homeButton + '</td>'
		buttonHTML += '<td valign="bottom" align="right"><a href="/article/0,3045,149-0-0-4339,00.html"><img src="/images/apcentral/but_apcom.gif" alt="AP Community: Contact a colleague or join an Electronic Discussion Group." width="106" height="30" border="0"></a></td>'
		buttonHTML += '<td valign="bottom" align="right"><a href="http://apps.apcentral.collegeboard.com/ResourceSearchParams.jsp"><img src="/images/apcentral/but_teachers.gif" alt="Teachers\' Resources: Reviews of teaching resources." width="134" height="30" border="0"></a></td>'
		buttonHTML += '<td valign="bottom" align="right"><a href="http://apps.apcentral.collegeboard.com/EventSearchParams.jsp"><img src="/images/apcentral/but_institutes.gif" alt="Institutes &amp; Workshops: Find a professional development opportunity." width="153" height="30" border="0"></a></td>'
		buttonHTML += '<td valign="bottom" align="right"><a href="http://apps.apcentral.collegeboard.com/FAQListing.jsp"><img src="/images/apcentral/but_faq.gif" alt="FAQs: Frequently Asked Questions about the Advanced Placement Program and AP Central." width="48" height="30" border="0"></a></td>'
		buttonHTML += '<td valign="bottom" align="right"><a href="http://apps.apcentral.collegeboard.com/ContactUs.jsp"><img src="/images/apcentral/but_contact.gif" alt="Contact AP: Submit a question, comment, or suggestion to AP Central." width="82" height="30" border="0"></a></td>'	
		var headerPhoto = '<IMG SRC="/images/apcentral/Photo2.gif" WIDTH="373" HEIGHT="92" ALT="">';
		var loggedMessage = 'You are logged in....<a href="http://apps.apcentral.collegeboard.com/Logout.jsp" class="arialEleven006699Bold">Logout?</a>';
	} else {
		var urlStrList = urlStr.split("/");
		var testPat = eval('/' + urlStrList[3] +'/');
		if (testPat == null || testPat.test("homepage")) { 
			homeButton = '<img src="/images/apcentral/but_home_on.gif" alt="Home: AP Central home page.">';
			var breadCrumbLink = '';
		} else { 
			homeButton = '<a href="/homepage/1,3056,,00.html"><img src="/images/apcentral/but_home.gif" alt="Home: AP Central home page." width="66" height="30" border="0"></a>';
			var breadCrumbLink = '<a href="/homepage/1,3056,,00.html" class="arialEleven006699Bold">Home</a>'
		}
		buttonHTML += '<td valign="bottom" align="right"><img src="/images/null_1x1.gif" alt="" width="243" height="30" border="0"></a></td>'
		buttonHTML += '<td valign="bottom">' + homeButton + '</td>'
		buttonHTML += '<td valign="bottom" align="right"><a href="http://apps.apcentral.collegeboard.com/RegWiz1.jsp"><img src="/images/apcentral/but_register.gif" alt="Register: Become a member...it\'s free and easy!" width="84" height="30" border="0"></a></td>'
		buttonHTML += '<td valign="bottom" align="right"><a href="http://apps.apcentral.collegeboard.com/Login.jsp"><img src="/images/apcentral/but_login.gif" alt="Login: Returning members start here." width="66" height="30" border="0"></a></td>'
		buttonHTML += '<td valign="bottom" align="right"><a href="http://apps.apcentral.collegeboard.com/FAQListing.jsp"><img src="/images/apcentral/but_faq.gif" alt="FAQs: Frequently Asked Questions about the Advanced Placement Program and AP Central." width="48" height="30" border="0"></a></td>'
		buttonHTML += '<td valign="bottom" align="right"><a href="http://apps.apcentral.collegeboard.com/ContactUs.jsp"><img src="/images/apcentral/but_contact.gif" alt="Contact AP: Submit a question, comment, or suggestion to AP Central." width="82" height="30" border="0"></a></td>'
		var headerPhoto = '<IMG SRC="/images/apcentral/Photo1.gif" WIDTH="373" HEIGHT="92" ALT="">';
		var loggedMessage = 'You are not logged in....<a href="http://apps.apcentral.collegeboard.com/RegWiz1.jsp">Register</a> or <a href="http://apps.apcentral.collegeboard.com/Login.jsp">Login?</a>   ';
	}	
			
		
  	if (urlStr.indexOf("unauthorized") > -1) {
		var breadCrumbLink = '';
	}
	
	//view images in a correctly-sized window
	function popup_image(src,w,h,alt) {
		if (h=="") {h = 300}
		if (w=="") {w = 300}	
		var win_parameters = "width=" + w + ",height=" + h + ",resizable=yes";
		var winTwo = eval("window.open('','Image Viewer',win_parameters)");
		winTwo.document.write('<html><head><title>Image Viewer</title></head><body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">');
		winTwo.document.write('<img src="../../../../kedigh/apcs/collegeboard/APJavaSubsetLanguageFeatures_files/%27%20+%20src%20+%20%27" width="' + w + '" height="' + h + '" alt="' + alt + '" border="0"></body></html>');
		// if window was already open, may have to resize
		winTwo.resizeTo(w,h);
		winTwo.focus();
		winTwo.document.close();
	}	

