﻿              var startInnerWidth, $internalCol, startColHeight;
              var mac=(navigator.platform.toLowerCase().indexOf("mac") != -1) ? true : false;

               function xtractFile(data){
     	var m = data.replace(/#.*/,"").match(/(.*)[\/\\]([^\/\\]+\.\w+)$/);
     	m=(m==null?new Array("",data,"index.html"):m);
      	return {file: m[2]}
              }
              var filename=xtractFile(window.location.href).file;

            function getNewsFeed() {
	$('#newsleft').rssfeed('http://www.blogger.com/feeds/6036508876594516316/posts/default', {
		limit: 5,snippet:false
	},
	function(e) { 
	var mHeight=0;loadup=false;
		$(e).find('li').each(function(i,item) {
		  $('div:last',this).remove();
		  $(this).find('h4>a').contents().unwrap(); 
		  $(this).find('div>a').contents().unwrap(); //removes anchor - as floats on anchor, takes floats off images
		  $(this).find('img').removeAttr('width').removeAttr('height'); 
		  $(this).contents().filter(function(){ return this.nodeType != 1; }).wrap("<p></p>");
		});
                 		$(e).onImagesLoad({ 
                        	        selectorCallback: function($s) {
	                 		//$('#dbug').html($('#dbug').html()+' '+$(this).height()+' : '+$s.height());
			$(e).find('div.rssBody').vTicker({ showItems: 1, pause:10000,animation:'fade',height:0,direction:'down'})
			.css('visibility','visible');
	     	         }
                  		}); 
	//$('#dbug').html($(e).html());
	})
	.css('visibility','hidden');
           }


            var beforeW,afterW,nexus;

            function slideCycle(sel,index) {
	var s="";
            	sel.each(function(i,elem){ 
		var top=$(this);
		var slide = $('.showslide',this);
		nexus=index || 0;
		slide.cycle({   
			fx:     'fade',
			startingSlide:nexus,
			speed:  1000, 
			timeout: 10000, 
			width: '100%',
			fit:1,
			slideResize: 0,
			fastOnEvent:1,
			before: function(curr,next,opts) {//alert($(next).index())
				beforeW=curr.width+' '+opts.currSlide;
				$('.itemdetail',top).hide();
				$('.showslide').height($(next).height());
				//nexus=opts.nextSlide;
				//$('#dbug').html('BEFORE: opts.nextSlide: '+opts.nextSlide+' opts.currSlide: '+opts.currSlide);

			},
			after:  function(curr,next,opts) {
				afterW=curr.width+' '+opts.currSlide;
				$('.itemdetail',top).hide();
				$('.itemdetail',top).eq(opts.currSlide).fadeIn(800);
				nexus=opts.nextSlide;

				if($(this).css('opacity')==1 && $(this).css('display')=='none') {
					$(this).css('display','block');
					//$(this).eq(opts.currSlide).css('display','block');
				}
		                   //var db=$('#dbug').html();
		                   //$('#dbug').html(db+'<br/>AFTER: opts.nextSlide (nexus): '+opts.nextSlide+' opts.currSlide: '+opts.currSlide);
			}
		     })
	 
                   }) 
	s+=beforeW+' '+afterW;
//	$('#dbug').html(s);
             };
             $(function() {
                 var link=$("ul#menu li a[href='"+filename+"']");
                 $(link).parent('li').addClass("selected");
                 $('#revs').css('visibility','hidden')
                 startInnerWidth = (mac ? Math.abs($('.inner').width()) : Math.abs(screen.availWidth)-16); // make a guess at the vertical scrollbar width [16 is good for 1280]                
                 var size=(Math.abs($('.inner').width()) / startInnerWidth); 
	//alert(size); 
                 size=((Math.round(size*10)/10)*100); 
                 $('body').css('font-size',size+'%');

              //$('ul#menu').find('a:gt(1)').attr('href','#');
              //$('ul#menu li:nth-child(6),ul#menu li:nth-child(7)').find('a').attr('href','#');
              //$('ul#menu li:nth-child(6),ul#menu li:nth-child(7),ul#menu li:nth-child(9),ul#menu li:nth-child(12),ul#menu li:nth-child(15)').remove();

        	$('.slide-wrapper').onImagesLoad({ 
                        selectorCallback: function() {
          		slideCycle(this,0);
        	     }
        	});

	getNewsFeed();
	$('#n7').cycle({
    		fx:    'fade',
		timeout: 8000, 
    		delay: -1000
	});	
              });
$(window).load(function() { 
	$('#n7').css('font-size','110%').equalHeight();
});
$(window).resize(function() {
       $('.slide-wrapper').cycle('destroy');
       $('#n7').cycle('destroy');
       var size=(Math.abs($('.inner').width()) / startInnerWidth);
       size=((Math.round(size*10)/10)*100);
       $('body').css('font-size',size+'%');
       slideCycle($('.slide-wrapper'),nexus);
       getNewsFeed();
	$('#n7').css('font-size','110%').equalHeight().cycle({
    		fx:    'fade',
		timeout: 8000, 
    		delay: -1000
	});
       //return false;
}) 

