// JavaScript Document

//date time
tday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");tmonth=new Array("January","February","March","April","May","June","July","August","September","October","November","December");function GetClock(){d=new Date();nday=d.getDay();nmonth=d.getMonth();ndate=d.getDate();nyear=d.getYear();nhour=d.getHours();nmin=d.getMinutes();if(nyear<1000)nyear=nyear+1900;if(nhour==0){ap=" AM";nhour=12}else if(nhour<=11){ap=" AM"}else if(nhour==12){ap=" PM"}else if(nhour>=13){ap=" PM";nhour-=12}if(nmin<=9){nmin="0"+nmin}document.getElementById('clockbox').innerHTML=""+tday[nday]+", "+tmonth[nmonth]+" "+ndate+", "+nyear+" "+nhour+":"+nmin+ap+"";setTimeout("GetClock()",1000)}window.onload=GetClock;


//Image Slider

$(document).ready(function(){$(".paging").show();$(".paging a:first").addClass("active");var imageWidth=$(".window").width();var imageSum=$(".image_reel img").size();var imageReelWidth=imageWidth*imageSum;$(".image_reel").css({'width':imageReelWidth});rotate=function(){var triggerID=$active.attr("rel")-1;var image_reelPosition=triggerID*imageWidth;$(".paging a").removeClass('active');$active.addClass('active');$(".image_reel").animate({left:-image_reelPosition},500)};
rotateSwitch=function(){play=setInterval(function(){$active=$('.paging a.active').next();if($active.length===0){$active=$('.paging a:first')}rotate()},4000)};rotateSwitch();
$(".image_reel a").hover(function(){clearInterval(play)},function(){rotateSwitch()});$(".paging a").click(function(){$active=$(this);clearInterval(play);rotate();rotateSwitch();return false})});


// Quotator

(function($){
  $.fn.quotator = function(options){
    var container = this;
    var defaults = 
    {
      speed : 5000,
      json : "quotator_quotes.js"
    }
    
    var options = $.extend(defaults, options);
    
    var quotes_json = options.json;
    var quotes;
    
    $.getJSON(quotes_json, function(data){
    var quotesobject = eval(data.quotes);
    var index = 0;
    
    
    setInterval(changeQuote, options.speed);
    
    container.html(quotesobject[index].quote + "<div id='author'>" + quotesobject[index].author + "</div>");
    
    
    function changeQuote(){
      container.fadeOut(function(){
        container.html(quotesobject[index].quote + "<div id='author'>" + quotesobject[index].author + "</div>").fadeIn();
      });
      
      if(index == quotesobject.length - 1){
        index = 0;
      } else{
        index++;
      }
    }
      
  });
  return container;
}
})(jQuery);


// Collapsible text
if(document.getElementById){document.write('<style type="text/css">.texter {display:none; border-left:white 20px solid; color:#404040;}</style>')}var divNum=new Array("a1","a2","a3","a4","a5","a6","a7","a8","a9","a10","a11","a12","a13","a14","a15","a16","a17","a18","a19","a20","a21","a22","a23","a24","a25","a26","a27","a28","a29","a30","a31","a32");function openClose(theID){for(var i=0;i<divNum.length;i++){if(divNum[i]==theID){if(document.getElementById(divNum[i]).style.display=="block"){document.getElementById(divNum[i]).style.display="none"}else{document.getElementById(divNum[i]).style.display="block"}}else{document.getElementById(divNum[i]).style.display="none"}}}

//Tabs
$(document).ready(function(){
	$(".tabmenu > li").click(function(e){
		switch(e.target.id){
			case "new":
				//change status & style menu
				$("#new").addClass("active");
				$("#existing").removeClass("active");
				//display selected division, hide others
				$("div.new").fadeIn();
				$("div.existing").css("display", "none");
			break;
			case "existing":
				//change status & style menu
				$("#new").removeClass("active");
				$("#existing").addClass("active");
				//display selected division, hide others
				$("div.existing").fadeIn();
				$("div.new").css("display", "none");
			break;
		}
		//alert(e.target.id);
		return false;
	});
});
