jQuery.noConflict();
$j = jQuery;
$j().ready(
  function()
  {
    //httpsRedirect();
        
    // add the swf slideshow where appropriate
    if( $j('#slideshow-container').length ){
      var flashvars  = {};
      var params     = { wmode:'transparent' };
      var attributes = {};
	  $j('#slideshow-container').attr('src',''); // ie6 wants to show the image under the swf
      swfobject.embedSWF( '/_swf/slideshow.swf', 'slideshow-container', '348', '293', "9.0.115", "/_swf/expressInstall.swf", flashvars, params, attributes );
    }
    
	/*Apply tooltip to links with class="addtip", plus option to look inside 'speechdata.txt' for the tooltip markups*/
    if( $j('a.addtip').length ){
		$j('a.addtip').speechbubble();
	}
	/*$j('a.addtip').speechbubble({url:'/_inc/tooltipdata.txt'})
	Use this setup instead: <a href="http://www.yahoo.com" class="addspeech" rel="#speechbubble1">*/
	
	
	
    // add a tooltip message to the satisfaction guaranteed icon where available
    if( $j('.satisfaction-guarantee').length ){
      if( typeof( $j().tooltip ) != 'function' ) $j('body').append('<scr'+'ipt type="text/javascript" src="/_js/jquery.tooltip.min.js"></scr'+'ipt>');
      var msg = "<strong>100% Satisfaction Guarantee.</strong><br />Cancel your membership by email or phone during the first 14 days and we will refund your money. This offer is only valid for new members.";
      $j('.satisfaction-guarantee').each(
        function()
        {
          $j(this).attr('title', msg );
          $j(this).tooltip({
          	track: true,
          	delay: 0,
          	showURL: false,
          	showBody: " - ",
            extraClass: "info",
          	fade: 250
          });
        }
      )
    }
	
	// add rounded corner support to IE
		if( $j.browser.msie ) hackRoundedCorners();


  }
);


//---------------------------------------------------------------------
//  Slider function added to slide content from one coordinate to another and back by click, hover and or automatically.
//---------------------------------------------------------------------
function slide(element, x1, y1, speed1, x2, y2, speed2, method){
	if (method == 'auto') {
		$j(element).animate({right:x1, top:y1}, speed1);
		$j(element).parent().find('.toggle').toggle(function(){
			$j(element).animate({right:x2, top:y2}, speed2);
		}, function(){
			$j(element).animate({right:x1, top:y1}, speed1);
		});
	}else if (method == 'click') {
		$j(element).parent().find('.toggle').click(function(){
			var pclass = $j(element).parent().attr('class');
			if(pclass == 'closed') {
				$j(element).animate({right:x1, top:y1}, speed1);
				$j(element).parent().attr('class','opened');
				return false;
			} else if(pclass == 'opened') {
				$j(element).animate({right:x2, top:y2}, speed2);
				$j(element).parent().attr('class','closed');
				return false;
			}
		});
		$j(element).parent().click(function(e) {
            e.stopPropagation();
        });
		$j(document).click(function() {
            $j(element).animate({right:x2, top:y2}, speed2);
			$j(element).parent().attr('class','closed');
        });
	}else if (method == 'hover' || method == undefined) {
		$j(element).parent().find('.toggle').mouseenter(function(){
			$j(element).animate({right:x1, top:y1}, speed1);
		});
		$j(element).parent().mouseleave(function(){
			$j(element).animate({right:x2, top:y2}, speed2);
		});
	}
}


//---------------------------------------------------------------------
//  preload images
//---------------------------------------------------------------------
$j.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    $j("<img>").attr("src", arguments[i]);
  }
}
var imgs = [];
$j( 'img' ).each( 
  function()
  {
    imgs.push( this.src );
  }
);
$j.preloadImages( imgs.join('","') );


//---------------------------------------------------------------------
//  remove the border, add the extra markup (and remove the margin from the first h3)
//---------------------------------------------------------------------
function hackRoundedCorners()
{  
  // first stretch the height of the left column to match that height of the right column
  $j( 'td.green-ltgreen .inner' ).height( $j( '.curriculum' ).height() );  
  $j( window ).resize(
    function()
    {
      $j( 'td.green-ltgreen .inner' ).height(0);
      $j( 'td.green-ltgreen .inner' ).height( $j( '.curriculum' ).height() );
    }
  );

  $j( '.curriculum h3' ).eq(0).css({marginTop:0});
  // rounded corners for IE7 and up only
  if( $j.browser.msie && $j.browser.version > 6 ){
    $j( '.rounded' ).each(
      function()
      {
        var $this = $j(this);
        $this.css({border:0,backgroundColor:'transparent'}).find('.inner').wrap( '<div class="l"><div class="r"><div class="t"><div class="tr"><div class="b"><div class="br"></div></div></div></div></div></div>' );
      }
    );
  }
}


//---------------------------------------------------------------------
//  redirect out of https if necessary
//---------------------------------------------------------------------
function httpsRedirect()
{  
  var secured_pages = [ '' ]; // just an example
  
  var aurl    = window.location.href.split('/');
  var file    = aurl[aurl.length-1];
  var afile   = file.split('?');
  file        = afile[0];
  if( aurl[0] == 'https:' && secured_pages.indexOf( file )<0 ){
    aurl[0] = 'http:';
    window.location = aurl.join('/');
  }
}


//---------------------------------------------------------------------
// IE6/7 doesn't have an Array.indexOf property so add it if it doesn't exist.
//---------------------------------------------------------------------
if( !Array.prototype.indexOf ){
  Array.prototype.indexOf = function( obj, from )
  {
    from = ( from == null ) ? 0 : Math.max( 0, this.length + from );
    for( var i = from, j = this.length; i < j; i++ ) if (this[i] === obj) return i;
    return -1;
  };
}


//---------------------------------------------------------------------
//  Slider Script
//---------------------------------------------------------------------


function MM_reloadPage(init) {  //Updated by PVII. Reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { // v4.01  
  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);  
  if(!x && d.getElementById) x=d.getElementById(n); return x;  
}

function slider(){//v2.3
// Copyright 2002-2004, Marja Ribbers-de Vroed, FlevOOware (www.flevooware.nl/dreamweaver/)
var v1=arguments,v2=v1[0],v3=MM_findObj(v2),v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20=window,v21=navigator;if (v3){v4=parseInt(v1[1]);v5=parseInt(v1[2]);v6=parseInt(v1[3]);v7=(v1.length>4)?parseInt(v1[4]):0;v8=(v1.length>5)?parseInt(v1[5]):0;v9=10;v10=document.layers?v3:v3.style;if (v3.SL1!=null){clearTimeout(v3.SL1);}v11=isNaN(parseInt(v10.left))?v3.offsetLeft:parseInt(v10.left);v12=isNaN(parseInt(v10.top))?v3.offsetTop:parseInt(v10.top);if (v8!=0){if (v8==1){v4=v11-v4;v5=v12;}else if (v8==2){v4=v11+v4;v5=v12;}else if (v8==3){v5=v12-v5;v4=v11;}else {v5=v12+v5;v4=v11;}}v13=v4;v14=v5;if ((v11!=v4)||(v12!=v5)){if (v7>0){v9=v6;v15=v7;v16=v7,v17=Math.abs(v11-v4),v18=Math.abs(v12-v5);if (v17<v18){v16=(v17!=0)?((v18/v17)*v7):v7;}else {v15=(v18!=0)?((v17/v18)*v7):v7;}if (v15>=v17){v15=Math.min(Math.ceil(v15),v7);}if (v16>=v18){v16=Math.min(Math.ceil(v16),v7);}if ((v11<v4)&&(v11+v15<v4)){v4=v11+v15;}if ((v11>v4)&&(v11-v15>v4)){v4=v11-v15;}if ((v12<v5)&&(v12+v16<v5)){v5=v12+v16;}if ((v12>v5)&&(v12-v16>v5)){v5=v12-v16;}}else {v17=((v4-v11)/v6);v18=((v5-v12)/v6);v17=(v17>0)?Math.ceil(v17):Math.floor(v17);v4=v11+v17;v18=(v18>0)?Math.ceil(v18):Math.floor(v18);v5=v12+v18;}v19=(document.layers||window.opera)?"":"px";if (v17!=0){v10.left=v4+v19;}if (v18!=0){v10.top=v5+v19;}var v22="flvFSL1('"+v2+"',"+v13+","+v14+","+v6+","+v7+",0)";v3.SL1=setTimeout(v22,v9);}else {if (v20.onSlideEnd){onSlideEnd(v2);}}}}

