// JavaScript Document




//to set the default tab use /css/global.css and set this to the same
var lsearch = "tab_events";
var timer = null;
function showTab(tab) {
	if (lsearch != "") {
		document.getElementById(lsearch).style.display = "none";
		tab_link = eval('document.getElementById(\'cp_link_'+ lsearch +'\')');
		tab_link.className = 'cp_tab_off';
		lsearch = tab;
	}
	var tsearch = document.getElementById(tab);
	tsearch.style.display = "block";
	tab_link = eval('document.getElementById(\'cp_link_'+ tab +'\')');
	tab_link.className = 'cp_tab_on';
	//set cookie for search persistance
	//document.cookie = "searchy="+tab;
	
	//getCookie('current_tab');
	setCookie('current_tab', tab, '', '/');
}







//to set the default tab use /css/global.css and set this to the same
var lsearch_content = "tab_content_comments";
var timer = null;
function showTabContent(tab) {
	if (lsearch_content != "") {
		document.getElementById(lsearch_content).style.display = "none";
		tab_link = eval('document.getElementById(\'cp_link_'+ lsearch_content +'\')');
		tab_link.className = 'cp_tab_off';
		lsearch_content = tab;
	}
	var tsearch = document.getElementById(tab);
	tsearch.style.display = "block";
	tab_link = eval('document.getElementById(\'cp_link_'+ tab +'\')');
	tab_link.className = 'cp_tab_on';
	//set cookie for search persistance
	//document.cookie = "searchy="+tab;
	
	//getCookie('current_tab');
	setCookie('current_content_tab', tab, '', '/');
}








var tmenu = ""
function showMe(nav) {
		clearTimeout(timer);
		goNow();
		var smenu = document.getElementById("snav"+nav);
		if (smenu) smenu.style.display="block";
		tmenu = nav;
		
}

function hideMe(nav) {
	timer = setTimeout("goNow();", 1000);
	document.getElementById('mnav'+nav).className='mnav';
}

function goPrevious(pid) {
	var p = document.getElementById(pid);
	var d = document.getElementById('comments');
	var y = findPosY(d);
	var z = findPosY(p)-y-10;
	d.scrollTop = z;
}
function growMe(div) {
	div.style.height ="200px";	
}
function shrinkBack(div) {
	div.style.height ="100px";	
}
function goNow() {
	clearTimeout(timer);
	if (tmenu != "") {
			var hmenu = document.getElementById("snav"+tmenu);
			hmenu.style.display = "none";
	}
}
function showDiv(div) {
		var d = document.getElementById(div);
		d.style.display = "block";
		window.scrollTo(0,findPosY(d));
}
function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} else if (obj.y) {
		curtop += obj.y;
	}
		return curtop;
}
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	} else if (obj.x)
		curleft += obj.x;
	return curleft;
}
function equalizeIt() {
	return;

	var a = document.getElementById('side_left');
	var b = document.getElementById('side_right');
	var ac = document.getElementById('right_left_bottom');
	var bc = document.getElementById('right_right_bottom');
	
	
	if (a.offsetHeight> b.offsetHeight)  {
		var oset = a.offsetHeight - b.offsetHeight;
		if (bc) bc.style.height += (bc.offsetHeight + oset)+"px";
	} else {
		var oset = b.offsetHeight - a.offsetHeight;
		if (ac) ac.style.height += (ac.offsetHeight + oset)+"px";
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}








/* ======================


Added by Marc Steel

====================== */


	
	

//=========== FORM VALIDATION FUNCTIONS



function stripSpaces(str) {
	//wrapper for a legacy function
	return trim(str);
}//stripSpaces


function trim(str) {
	return str.replace(/^\s*|\s*$/g,"");
}

function validEmail(str) {
	emailEXP = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2}[mtgvu]?$/i;


	if (!emailEXP.test(str)) {
		return false;
	} else {
		return true;
	}
}

function validZipCode(str) {
	numEXP = /^\d{5}(-\d{4})?$/;

	if (!numEXP.test(str)) {
		return false;
	} else {
		return true;
	}
}

function validPhoneNumber(str) {
	phoneEXP = /^(\d{3}\-\d{3}\-\d{4}$|\d{3}\.\d{3}\.\d{4}$|\d{3}\ \d{3}\ \d{4}$|\d{10}$)/

	if (!phoneEXP.test(str)) {
		return false;
	} else {
		return true;
	}
}

function validURL(str) {
	exp = /^((ht|f)tp(s?))?\:\/\/([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\S*)?$/

	if (!exp.test(str)) {
		return false;
	} else {
		return true;
	}
}






	
	function cpMovieSlideShowChanger(img_id, img_num) {
		eval("document.cpMovieThumb_"+ img_id +".src=\'/images/movies/"+ img_id +"/"+ img_num +".jpg\'");
	}


	
	
	function checkboxCheckerUnchecker(form_name, id_group, group_number) {
		var cb; //checkbox object
		
		if (group_number == undefined) cb = document[form_name][id_group];
		
		else cb = document[form_name][id_group][group_number];

		if (cb.checked) { cb.checked = false }
		else cb.checked = true;
		
	}



	var thisWindow;

	
	function cpMusicStorePopper(apollo_key) {
		var w = 400;
		var h = 400;
		var t = 10;
		var l = 10;
	
		
		var params = "scrollbars=1,resizable=1,status=0,location=0,width="+ w +",height="+ h;
	
		if (thisWindow && !thisWindow.closed) { thisWindow.focus(); }
			else {
		
			thisWindow = window.open(
				'http://www.apolloaudio.com/lt.asp?name='+ apollo_key,
				"cpMusicStore",
				params
			);
	
			thisWindow.focus();
		}
	}








	
	function cpLocalSupportPopper() {
		var w = 670;
		var h = 600;
		var t = 10;
		var l = 10;
	
		
		var params = "scrollbars=1,resizable=1,status=0,location=0,width="+ w +",height="+ h;
	
		if (thisWindow && !thisWindow.closed) { thisWindow.focus(); }
			else {
		
			thisWindow = window.open(
				'http://podcast.citypaper.net/player2.php',
				"cpLocalSupport",
				params
			);
	
			thisWindow.focus();
		}
	}












	function rowBGColor(row, color) {
		if (document.getElementById) {
			row.style.backgroundColor = color;
		}
	}
	
	
	
	function objClass(obj, className) {
		if (obj) {
			obj.className = className;
		}
	}
	
		
	
	function cpPlaceArchiveLinks() {
		for(loop=1;loop<=links.length;loop++) {
			var linkSub = '';
			var linkAuthor = '';
			if (links[loop].sub) {
				linkSub = '<br /><span class="tealsub">' + links[loop].sub + '</span>';
			}
			if (links[loop].author) {
				linkAuthor = '<br /><span style="font-style: italic; text-align: right; margin: 0px;">&#151;' + links[loop].author + '</span>';
			}
			document.writeln('<p><a href="' + links[loop].source + '" class="archive_section_nav_link" style="font-weight: bold;">' + links[loop].title + '</a>' + linkSub + linkAuthor + '</p>');
		}
	}//cpPlaceArchiveLinks()
	
	
	
	function cpContactUsListNav(select) {
		
		str = select.options[select.selectedIndex].value;
		
		window.location = '/contact-us/index.php#'+ str;
		
	}
	
	
	


	function cpStoryImagePopper(path) {
	
		var w = 400;
		var h = 350;
		
		var params = "scrollbars=1,resizable=1,status=0,location=0,width="+ w +",height="+ h;
	
		thisWindow = window.open(
			'/popups/story_image.php?path='+path,
			'',
			params
		);
	
		thisWindow.focus();
	}	





	function cpMadeInPhillyMapPopper(path) {
	
		var w = 400;
		var h = 350;
		
		var params = "scrollbars=1,resizable=1,status=0,location=0,width="+ w +",height="+ h;
	
		thisWindow = window.open(
			'/articles/_materials/2007/02/08/made_in_philly_google_map_include.php',
			'',
			params
		);
	
		thisWindow.focus();
	}
	
	





	function cpFootnote(article_id, note_number) {
	
		var w = 400;
		var h = 350;
		
		var params = "scrollbars=1,resizable=1,status=0,location=0,width="+ w +",height="+ h;
	
		thisWindow = window.open(
			'/popups/footnotes.php?article_id='+ article_id +'#'+ note_number,
			'',
			params
		);
	
		thisWindow.focus();
	}
	
	
	
	
	



	function cpDJNightsLocationPopper(venue) {
	
		var w = 580;
		var h = 350;
		
		var params = "scrollbars=1,resizable=1,status=0,location=0,width="+ w +",height="+ h;
	
		thisWindow = window.open(
			'/music/dj-nights/venue_popup.php?venue='+ venue,
			'djnights_venue',
			params
		);
	
		thisWindow.focus();
	}
	
	
	
	
		
	function hideShow(objID) {
	
		if (document.getElementById) {
			var curObj = document.getElementById(objID);
			var curStatus = curObj.style.display;
			
			if (curStatus == 'block') curObj.style.display = 'none';
			else curObj.style.display = 'block';
		}
	}
	
	
	
	
	
	
	
	function cpSubmitEmailToMailingList(location) {
	
		if (location == 'footer') {
			var email = document.getElementById('mailing_list_email_footer').value;
			var source = document.getElementById('mailing_list_source_footer').value;
			var div_name = 'ajax_status_mailing_list_footer';
		} else if (location == 'home') {
			var email = document.getElementById('mailing_list_email_home').value;
			var source = document.getElementById('mailing_list_source_home').value;
			var div_name = 'ajax_status_mailing_list_home';
		} else {
			var email = document.getElementById('mailing_list_email').value;
			var source = document.getElementById('mailing_list_source').value;
			var div_name = 'ajax_status_mailing_list';
		}
		
		var url = '/includes/ajax/mailing_list.php?db=web_db&source=' + source +'&email='+ email;
		
		var no_close_link = 1;
		
		
	//	if (!validEmail(email)) {
	//		alert('Please enter a valid email address.');
	//		return false;
	//	} else {
	 		urlToTargetDiv(url, div_name, no_close_link)
	// 	}
	
	/*
			cpAjaxSQL('insert into <?= TABLE_MAILING_LIST_EMAILS ?> (ml_email) values (\''+ email +'\')', 'web_db');
		}
	*/
	}
	
	
	
	function classifieds_search_submit(frm) {
		
		id = frm.searchOnlineCategoryID.options[frm.searchOnlineCategoryID.selectedIndex].value;
		ids = 'aaa';

		id_split = id.split(':');
		
		category_id = id_split[0];
		classification_id = id_split[1];
		
		var url = '';
		url += 'http://classifieds.citypaper.net/index.cfm?searchOnlineCategoryID='+ category_id;
		if (classification_id != undefined) url += '&searchOnlineSectionID='+ classification_id;
		
		if (frm.classifieds_search_keywords.value != '') url += '&keywords='+ frm.classifieds_search_keywords.value;
		
		
		window.open(url);
		
		return false;
		
	}



	function urlencode(str) {
		str = escape(str);
		str = str.replace('+', '%2B');
		str = str.replace('%20', '+');
		str = str.replace('*', '%2A');
		str = str.replace('/', '%2F');
		str = str.replace('@', '%40');

		return str;
	}




	function agenda_panel_submitter() {

		frm = document.frmEvents;
		

		
		
		/*
		start = cal1.getFormatedDate();
		


		start_year = start.substring(0,4)
		start_month = start.substring(5,7)
		start_day = start.substring(8,10)
		
		frm.start_year.value = start_year;
		frm.start_month.value = start_month;
		frm.start_day.value = start_day;
		*/
	
	/*	
		end = frm.end_date.value;
		end_year = end.substring(0,4)
		end_month = end.substring(5,7)
		end_day = end.substring(8,10)
	*/
		/*
		frm.end_year.value = start_year;
		frm.end_month.value = start_month;
		frm.end_day.value = start_day;
*/
		
		frm.submit();
	}//agenda_panel_submitter






	function cpAddEventToUserCalendar(event_id, user_id) {
			
		url = '/includes/ajax/agenda_event_to_user.php?';
		url += 'event_id='+ event_id;
		url += '&user_id='+ user_id;
		url += '&insert='+ 1;
		
		clearTimeout(oneToManyTimeout);
		urlToTargetDiv(url, 'event_to_user_status');
		oneToManyTimeout = setTimeout("document.getElementById('event_to_user_status').style.display = 'none';", 2800);
		
		link = document.getElementById('add_to_calendar_link_'+ event_id);
		link.innerHTML = 'remove from my calendar';
		link.href = 'javascript:cpDeleteEventToUserCalendar(\''+ event_id +'\', '+ user_id +')';
	}



	function cpDeleteEventToUserCalendar(event_id, user_id) {
		url = '/includes/ajax/agenda_event_to_user.php?';
		url += 'event_id='+ event_id;
		url += '&user_id='+ user_id;
		url += '&insert='+ 0;
		
		clearTimeout(oneToManyTimeout);
		urlToTargetDiv(url, 'event_to_user_status');
		oneToManyTimeout = setTimeout("document.getElementById('event_to_user_status').style.display = 'none';", 2800);
		
		link = document.getElementById('add_to_calendar_link_'+ event_id);
		link.innerHTML = 'add to my  calendar';
		link.href = 'javascript:cpAddEventToUserCalendar(\''+ event_id +'\', '+ user_id +')';
	}
	
	
	
	
	
	
	function cpAgendaCategorySelect(list) {
		selIndex = list.selectedIndex;
		//if (selIndex == 0) return false;
		
		id = list.options[selIndex].value;
		text = escape(stripSpaces(list.options[selIndex].text));
		text = text.replace(/\//g, '-');
		text = text.replace(/\s/g, '+');
		
		window.location = '/agenda/category/'+ id +'/'+text;
	}
	
	
		
	
	
	
	function cpAgendaBulletinSelect(list) {
		selIndex = list.selectedIndex;
		//if (selIndex == 0) return false;
		
		id = list.options[selIndex].value;
		text = escape(stripSpaces(list.options[selIndex].text));
		text = text.replace(/\//g, '-');
		text = text.replace(/\s/g, '+');
		
		window.location = '/agenda/bulletin/'+ id +'/'+text;
	}
	
	
	
		
	
	
	
	function cpAgendaBulletinSelectWeekly(list) {
		selIndex = list.selectedIndex;
		//if (selIndex == 0) return false;
		
		id = list.options[selIndex].value;
		text = escape(stripSpaces(list.options[selIndex].text));
		text = text.replace(/\//g, '-');
		text = text.replace(/\s/g, '+');
		
		window.location = '/agenda/bulletin/weekly/'+ id +'/'+text;
	}
	
	
	
	
	
	
	function cpImeem(imeem) {
		//alert(imeem)
		
		var content = '<div style="width:230px;"><object width="230" height="110"><param name="movie" value="http://media.imeem.com/m/'+ imeem +'/"></param><param name="wmode" value="transparent"></param><embed src="http://media.imeem.com/m/'+ imeem +'/" type="application/x-shockwave-flash" width="230" height="110" wmode="transparent"></embed></object><div style="background-color:#E6E6E6;padding:1px;"><div style="float:left;padding:4px 4px 0 0;"><a href="http://www.imeem.com/"><img src="http://www.imeem.com/embedsearch/E6E6E6/" border="0"  /></a></div><form method="post" action="http://www.imeem.com/embedsearch/" style="margin:0;padding:0;"><input type="text" name="EmbedSearchBox" /><input type="submit" value="Search" style="font-size:12px;" /><div style="padding-top:3px;"><a href="http://www.imeem.com/ads/banneradclick.ashx?ep=0&ek='+ imeem +'" rel="nofollow"><img src="http://www.imeem.com/ads/bannerad/152/10/" border="0" /></a><a href="http://www.imeem.com/ads/banneradclick.ashx?ep=1&ek='+ imeem +'" rel="nofollow"><img src="http://www.imeem.com/ads/bannerad/153/10/" border="0" /></a><a href="http://www.imeem.com/ads/banneradclick.ashx?ep=2&ek='+ imeem +'" rel="nofollow"><img src="http://www.imeem.com/ads/bannerad/154/10/" border="0" /></a><a href="http://www.imeem.com/ads/banneradclick.ashx?ep=3&ek='+ imeem +'" rel="nofollow" ><img src="http://www.imeem.com/ads/bannerad/155/10/'+ imeem +'/" border="0" /></a></div></form></div></div>';
		
		var imeem_div = 'cp_imeem_'+ imeem;
		
		
		document.getElementById(imeem_div).innerHTML = content;
		hideShow(imeem_div);
	}
	
	
	
		
	
	
	
	function cpLaLa(lala) {
		//alert(imeem)
		
		var content = '<object type="application/x-shockwave-flash" data="http://www.lala.com/external/flash/SingleSongWidget.swf" id="lalaSongEmbed" width="220" height="70"><param name="movie" value="http://www.lala.com/external/flash/SingleSongWidget.swf"/><param name="wmode" value="transparent"/><param name="allowNetworking" value="all"/><param name="allowScriptAccess" value="always"/><param name="flashvars" value="songLalaId='+ lala +'&host=www.lala.com&partnerId=membersong"/><embed id="lalaSongEmbed" name="lalaSongEmbed" src="http://www.lala.com/external/flash/SingleSongWidget.swf" width="220" height="70" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" allowNetworking="all" allowScriptAccess="always" flashvars="songLalaId='+ lala +'&host=www.lala.com&partnerId=membersong"></embed></object>';
		
		var lala_div = 'cp_lala_'+ lala;
		
		
		document.getElementById(lala_div).innerHTML = content;
		hideShow(lala_div);
	}
	
	
	
	
	
	function blogs_stat(blog_type, blog_name, page_type, slug, stat_post_id) {
		
		url = '/includes/ajax/blog_stats.php?blog_name='+ blog_name +'&';
		url += 'page_type='+ page_type +'&';
		url += 'slug='+ slug +'&';
		url += 'stat_post_id='+ stat_post_id +'&';
		url += 'blog_type='+ blog_type +'&';
		
		target_div = 'blogs_stats_result';
		
		urlToTargetDiv(url, target_div, 0);
		
	}
	
	
	
	