$j(document).ready(function(){
 
	//$j("div").hide();	  
	  
	var globalPopUp = null;
 
   // ***************************
   // POP UP WINDOW
   // ***************************
    $j.fn.popOpen = function(popID,popURL,zindex){
		
		//popID = setpopID!=null?jQuery(this).attr('rel'):setpopID; //Get Popup Name
		//popURL = setpopURL!=null?jQuery(this).attr('href'):setpopURL; //Get Popup href to define size
	    globalPopUp = popID;
	 	zindex = zindex==null?'99999':zindex;
		 
		//Pull Query & Variables from href URL
		query= popURL.split('?');
		dim= query[1].split('&');
		popWidth = dim[0].split('=')[1]; //Gets the first query string value
		
		popIDStr = "#"+popID+"";
		//Fade in the Popup and add close button
		$j('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="javascript: void(0);" onclick="$j(this).popClose(this);"><img src="images/close_pop.png" class="btn_close" title="Close Window" alt="Close" border="0"/></a>');
		
		//Define margin for center alignment (vertical + horizontal) - we add 80 to the height/width to accomodate for the padding + border width defined in the css
		var popMargTop = ($j('#' + popID).height() + 80) / 2;
		var popMargLeft = ($j('#' + popID).width() + 80) / 2;
		
		 
		
		//Apply Margin to Popup
		$j('#' + popID).css({ 
			'margin-top' : -popMargTop,
			'margin-left' : -popMargLeft,
			'z-index' : zindex
		});
		
		//Fade in Background
		$j('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
		$j('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer 
		
	};
 
	//When you click on a link with class of poplight and the href starts with a # 
	/*jQuery('a.poplight[href^=#]').click(function() {
		jQuery(this).popOpen(); //Run popOpen function on click
		return false;
	}); */
	
	
	$j.fn.popClose = function(popID){
 		$j('#fade , #'+globalPopUp).fadeOut(); //fade them both out
		$j('#fade').remove();
		return false;
	};
	
	//Close Popups and Fade Layer
	$j('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
	  	$j('#fade , .popup_block').fadeOut(); //fade them both out
		$j('#fade').remove();
		return false;
	});

	
	//Sequential List
   $j("#step li").each(function (i) {
		i = i+1;
		$j(this).addClass("item"+i);
	 });
   $j("#number li").each(function (i) {
		i = i+1;
		$j(this).addClass("item"+i);
	   });
	$j("#commentlist li").each(function (i) {
		i = i+1;
	$j(this).prepend('<span class="commentnumber"> #'+i+'</span>');
 });
	
});

 // Use Prototype with $(...), etc.
 //$('someid').hide();
