jQuery(function(){
	jQuery.noConflict();
	jQuery('ul.superfish').superfish({ 
            delay:       200,                            // one second delay on mouseout 
            animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
            speed:       'fast',                          // faster animation speed 
            autoArrows:  true,                           // disable generation of arrow mark-up 
            dropShadows: false                            // disable drop shadows 
        }); 
	
	var pagemenuwidth = jQuery("ul#page-menu").width();
	var pagemleft = Math.round((950 - pagemenuwidth) / 2);
	jQuery("ul#page-menu").css('padding-left',pagemleft);
	
	var catmenuwidth = jQuery("ul#cats-menu").width();
	var catmleft = Math.round((950 - catmenuwidth) / 2);
	jQuery("ul#cats-menu").css('padding-left',catmleft);
	
	if (!((jQuery(".custom-sidebar-block").length) == 0)) jQuery(".custom-sidebar-block").tabs({ fx: { opacity: 'toggle' } });
	
	if (!(typeof document.body.style.maxHeight === "undefined")) {
		jQuery("div#mainposts.notop div.mainpost-wrap").eq(0).addClass("topbg");
		jQuery("div#mainposts.notop div.mainpost-wrap").eq(1).addClass("topbg");
		jQuery("div.blogstyle.indexpage").eq(0).removeClass("blogstyle");
	}
});

////////////////////////////////////////////////////////////////////////////////
// Video window function, handles urls, sets up embeds, makes window visible/invisible
////////////////////////////////////////////////////////////////////////////////

function playVid(vidId, noBlackout) {

  ////////////////////////////////////////////////////////////////////////////////
  // Test to see if our video and blackout divisions have been set up.
  // If no division was declared in the HTML then we'll go ahead and automatically
  // create and style the necessary division.
  ////////////////////////////////////////////////////////////////////////////////

  if (_vidPane==null) {
     ////////////////////////////////////////////////////////////////////////////////
     /// Video Pane wasn't set up so see if it's declared in the HTML
     ////////////////////////////////////////////////////////////////////////////////
     _vidPane=document.getElementById('ads');
     //_blackout=document.getElementById('blackout');
  }

  // Shows (or hides) the vidPane layer.   Accepts 2 parameteres.
  // vidId is null (close window) or an anchor object (contains HREF value)
  // vidId is mandatory example: <a href="someservice.com/somevideo.swf" onClick='return playVid(this);'></a>
  // noBlackout is optional. If you pass true, the background will not be "greyed out".

  if (vidId==null) { 
     // Null is passed by the "close" link, so we'll hide the layer.
     _vidPane.style.display='none';         // Hide the division.
     _vidPane.innerHTML='';                 // purge it's html (kill video)
     //_blackout.style.display='none';        // Hide the blackout layer.
  } else {
     // Snag the url from the passed object
     vidId=vidId.href;
		
     // Next three lines make the blackout layer visible
     // and makes sure it covers the entire page.
     if (!noBlackout) {
        //_blackout.style.width='100%';
        //_blackout.style.height=(document.body.offsetHeight<screen.height) ? screen.height+'px' : document.body.offsetHeight+20+'px'; 
       // _blackout.style.display='block';
     } else {
        //_blackout.style.display='none';        // Hide the blackout layer.
     }
     // Break out the URL passed to this function (so vidInfo[0]=http, [1]=domain, etc
     var vidInfo = vidId.split('/');
		 var vidURL	 = vidId.split('/'); //added to get original url
     // We're building a temporary string called vidstring. 
     // vidstring will hold the HTML as we build it based on the service
     // being used.  The next few lines contains items which are common
     // to all the services, or at least ignored if not directly used.
     
     //var vidstring ='&nbsp;<A HREF="'+vidId+'">LINK</A>';
     //vidstring+='&nbsp;<A HREF="#" onClick="return(playVid())">CLOSE</A><BR>';
     //alert(vidURL);
				vidURL=vidId.match(/v=.+$/);
        vidURL=String(vidURL).replace(/v=/g,'');
     var vidstring ='<center>';
     vidstring+='<object width="561" height="344" type="application/x-shockwave-flash" data="http://www.youtube.com/v/'+vidURL+'&autoplay=1">';
     vidstring+='<param name="movie" value="http://www.youtube.com/v/'+vidURL+'&autoplay=1" />';
		 vidstring+-'<param name="wmode" value="transparent" />';
     vidstring+='<embed';  
     vidstring+=' enableJavascript="false" allowScriptAccess="never"';
     vidstring+=' type="application/x-shockwave-flash"';
     vidstring+=' wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" ';

     if (vidInfo[2].indexOf('youtube.com')>=0) {
        ////////////////////////////////////////////////////////////////////////////////
        // YouTube (Use browser URL, autoplays)
        ////////////////////////////////////////////////////////////////////////////////
        vidInfo=vidId.match(/v=.+$/);
        vidInfo=String(vidInfo).replace(/v=/g,'');
        //alert(vidInfo);
        vidstring+=' src="http://www.youtube.com/v/'+vidInfo+'&autoplay=1" ';
        vidstring+=' height="344" width="561"></embed></object></center>';
     } else {
        ////////////////////////////////////////////////////////////////////////////////
        // Failed.
        ////////////////////////////////////////////////////////////////////////////////
        vidstring += '></embed></object><br><br>Unknown video service.</center>';
     } 
     // Insert our HTML and display the video window.
     _vidPane.innerHTML=vidstring;
     // Set the Y position of the video window so it's in the visible clip
     var scrollTop = 0;
     if (document.documentElement && document.documentElement.scrollTop)
        scrollTop = document.documentElement.scrollTop;
     else if (document.body)
        scrollTop = document.body.scrollTop
     //_vidPane.style.top=scrollTop+50+'px';
     // Video window was hidden so we'll make it visible
     _vidPane.style.display='block'; 
  }
  // return false so the browser won't follow through with A HREF clicks.
  return(false);
}

// Initialize global variables.
var _savedTarget=null;        // The target layer (effectively vidPane)
var _orgCursor=null;          // The original Cursor (mouse) Style so we can restore it
var _vidPane = null;          // Video Layer -- won't be defined until a video is called
//var _blackout= null;          // blackout Layer. -- won't be defined until a video is called.

