$(document).ready(function() {
  
  //Look for 'expando' div -- if found, create expandable list
  if($('#expando').length != 0){
	  //Hide all answers
	  $('#expando h2').next().hide();  
	  //Allow collapsing
	  $('#expando h2').toggle(function(){
		$('#expando h2').next().hide('fast'); 
		$(this).next().show('slow');
		$(this).addClass('expanded');
	  }, function(){
		$(this).next().hide('slow');
		$(this).removeClass('expanded');
	  });
  }
  
});

//Hide/show all 
function expandAll(){ $('#expando h2').next().show('slow'); }
function collapseAll(){	$('#expando h2').next().hide('slow'); }

/* ==================================================================== */

function showPopup(thiswin) {
	//alert("here");
	tb_show('Fargo-Moorhead Convention &amp; Visitors Bureau', thiswin, null);
	//return false;
}
function showPopupWin(thiswin) {
	thiswidth = 600;
	thisheight = 400;
	if(thiswin != "") {
		window.open(thiswin, 'popwin', 'width=' + thiswidth + ',height=' + thisheight + ',scrollbars,resizable');
	}
}

function displayitems(thisstatus) {
	document.getElementById("sn_showhide").style.display = thisstatus;
}


/*
	function sortItems(thisid) {
		thiswidth = 500;
		thisheight = 450;
		window.open(thisid, 'sortpage', 'width=' + thiswidth + ',height=' + thisheight + ',scrollbars,resizable');
	}
*/
	
function showSocialNetworking() {
	document.getElementById('home_2009_social_network_popup').style.display = "block";
	document.getElementById('index2009_news').style.display = "none";
}
function hideSocialNetworking() {
	document.getElementById('home_2009_social_network_popup').style.display = "none";
	document.getElementById('index2009_news').style.display = "block";
}
function swaptabs(thisontab) {
	if(thisontab == "dealdisc") {
		document.getElementById('tabcontents_dealdisc').style.display = '';
		document.getElementById('tabcontents_photovideo').style.display = 'none';
		document.getElementById('tabcontents_specevents').style.display = 'none';
		document.getElementById('tablink_dealdisc').className = 'on';
		document.getElementById('tablink_photovideo').className = '';
		document.getElementById('tablink_specevents').className = '';
	}
	else if(thisontab == "photovideo") {
		document.getElementById('tabcontents_dealdisc').style.display = 'none';
		document.getElementById('tabcontents_photovideo').style.display = '';
		document.getElementById('tabcontents_specevents').style.display = 'none';
		document.getElementById('tablink_dealdisc').className = '';
		document.getElementById('tablink_photovideo').className = 'on';
		document.getElementById('tablink_specevents').className = '';
	}
	else {
		document.getElementById('tabcontents_dealdisc').style.display = 'none';
		document.getElementById('tabcontents_photovideo').style.display = 'none';
		document.getElementById('tabcontents_specevents').style.display = '';
		document.getElementById('tablink_dealdisc').className = '';
		document.getElementById('tablink_photovideo').className = '';
		document.getElementById('tablink_specevents').className = 'on';
	}
}
function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
	
function newspopup(thisid) {
	if (thisid != '') {
		//var WindowObjectReference = window.open('news_view.php?id=' + thisid, 'newswindow', 'width=500,height=400,scrollbars,resizable');
		//WindowObjectReference.focus();
		tb_show('Loaded onload', '/news_view.php?height=400&width=500&modal=true&id=' + thisid, null);
	}
}

function viewpage(thispage, thiswidth, thisheight) {
	var thiswindow;
	thiswindow = window.open(thispage, 'viewpage', 'width=' + thiswidth + ',height=' + thisheight + ',scrollbars,resizable=no');
	thiswindow.focus();
}

function viewpageid(thispage, thisid, thiswidth, thisheight) {
	var thiswindow;
	thiswindow = window.open(thispage + '?id=' + thisid, 'viewpage', 'width=' + thiswidth + ',height=' + thisheight + ',scrollbars,resizable=no');
	thiswindow.focus();
}

function viewEvent(thisid) {
	thiswidth = 600;
	thisheight = 400;
	if(thisid != "") {
		window.open('/calendarpopup.php?id=' + thisid, 'viewevent', 'width=' + thiswidth + ',height=' + thisheight + ',scrollbars,resizable');
	}
}

function removejscssfile(filename, filetype){
 var targetelement=(filetype=="js")? "script" : (filetype=="css")? "link" : "none" //determine element type to create nodelist from
 var targetattr=(filetype=="js")? "src" : (filetype=="css")? "href" : "none" //determine corresponding attribute to test for
 var allsuspects=document.getElementsByTagName(targetelement)
 for (var i=allsuspects.length; i>=0; i--){ //search backwards within nodelist for matching elements to remove
  if (allsuspects[i] && allsuspects[i].getAttribute(targetattr)!=null && allsuspects[i].getAttribute(targetattr).indexOf(filename)!=-1)
   allsuspects[i].parentNode.removeChild(allsuspects[i]) //remove element by calling parentNode.removeChild()
 }
}

