// Top Navigation
$(document).ready(function() {
	

	function megaHoverOver(){
		$(this).find(".sub").stop().fadeTo('fast', 1).show();
		
			
		//Calculate width of all ul's
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				$(this).find("ul").each(function() {					
					rowWidth += $(this).width(); 
				});	
			};
		})(jQuery); 
		
		if ( $(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			//Calculate each row
			$(this).find(".row").each(function() {							   
				$(this).calcSubWidth();
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			//Set width
			$(this).find(".sub").css({'width' :biggestRow});
			$(this).find(".row:last").css({'margin':'0'});
			
		} else { //If row does not exist...
			
			$(this).calcSubWidth();
			//Set Width
			$(this).find(".sub").css({'width' : rowWidth});
			
		}
	}
	
	function megaHoverOut(){ 
	  $(this).find(".sub").stop().fadeTo('fast', 0, function() {
		  $(this).hide(); 
	  });
	}
	var config = {    
		 sensitivity: 100, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 200, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 100, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};
	$("ul#topnav li .sub").css({'opacity':'0'});
	$("ul#topnav li").hoverIntent(config);
});
//scroll to top
var scrolltotop={
	//startline: Integer. Number of pixels from top of doc scrollbar is scrolled before showing control
	//scrollto: Keyword (Integer, or "Scroll_to_Element_ID"). How far to scroll document up when control is clicked on (0=top).
	setting: {startline:100, scrollto: 0, scrollduration:1000, fadeduration:[500, 100]},
	controlHTML: '<img src="assets/images/go_up.png" style="width:80px; height:20px" />', //HTML for control, which is auto wrapped in DIV w/ ID="topcontrol"
	controlattrs: {offsetx:10, offsety:0}, //offset of control relative to right/ bottom of window corner
	anchorkeyword: '#top', //Enter href value of HTML anchors on the page that should also act as "Scroll Up" links

	state: {isvisible:false, shouldvisible:false},

	scrollup:function(){
		if (!this.cssfixedsupport) //if control is positioned using JavaScript
			this.$control.css({opacity:0}) //hide control immediately after clicking it
		var dest=isNaN(this.setting.scrollto)? this.setting.scrollto : parseInt(this.setting.scrollto)
		if (typeof dest=="string" && jQuery('#'+dest).length==1) //check element set by string exists
			dest=jQuery('#'+dest).offset().top
		else
			dest=0
		this.$body.animate({scrollTop: dest}, this.setting.scrollduration);
	},

	keepfixed:function(){
		var $window=jQuery(window)
		var controlx=$window.scrollLeft() + $window.width() - this.$control.width() - this.controlattrs.offsetx
		var controly=$window.scrollTop() + $window.height() - this.$control.height() - this.controlattrs.offsety
		this.$control.css({left:controlx+'px', top:controly+'px'})
	},

	togglecontrol:function(){
		var scrolltop=jQuery(window).scrollTop()
		if (!this.cssfixedsupport)
			this.keepfixed()
		this.state.shouldvisible=(scrolltop>=this.setting.startline)? true : false
		if (this.state.shouldvisible && !this.state.isvisible){
			this.$control.stop().animate({opacity:1}, this.setting.fadeduration[0])
			this.state.isvisible=true
		}
		else if (this.state.shouldvisible==false && this.state.isvisible){
			this.$control.stop().animate({opacity:0}, this.setting.fadeduration[1])
			this.state.isvisible=false
		}
	},
	
	init:function(){
		jQuery(document).ready(function($){
			var mainobj=scrolltotop
			var iebrws=document.all
			mainobj.cssfixedsupport=!iebrws || iebrws && document.compatMode=="CSS1Compat" && window.XMLHttpRequest //not IE or IE7+ browsers in standards mode
			mainobj.$body=(window.opera)? (document.compatMode=="CSS1Compat"? $('html') : $('body')) : $('html,body')
			mainobj.$control=$('<div id="topcontrol">'+mainobj.controlHTML+'</div>')
				.css({position:mainobj.cssfixedsupport? 'fixed' : 'absolute', bottom:mainobj.controlattrs.offsety, right:mainobj.controlattrs.offsetx, opacity:0, cursor:'pointer'})
				.attr({title:'Scroll Back to Top'})
				.click(function(){mainobj.scrollup(); return false})
				.appendTo('body')
			if (document.all && !window.XMLHttpRequest && mainobj.$control.text()!='') //loose check for IE6 and below, plus whether control contains any text
				mainobj.$control.css({width:mainobj.$control.width()}) //IE6- seems to require an explicit width on a DIV containing text
			mainobj.togglecontrol()
			$('a[href="' + mainobj.anchorkeyword +'"]').click(function(){
				mainobj.scrollup()
				return false
			})
			$(window).bind('scroll resize', function(e){
				mainobj.togglecontrol()
			})
		})
	}
}

scrolltotop.init()
//menu animation
$(document).ready(function(){
$('#page').animate({ "top": "0px"}, 3000,
										  
function(){
	$("#topnav li a").hover(
	function() {
		$(this).animate({"top": "-5"},  "easeOut");
	},
	function() {
		$(this).animate({"top": "3"},  "easeOut");
		$(this).animate({"top": "0"},  "easeOut");
	});


});	
		
$('.leftside').animate({ "top": "0px"}, 1500,
										  
function(){
	$(".leftside ul.innermenu li a").hover(
	function() {
		$(this).animate({"left": "5"},  "easeOut");
	},
	function() {
		$(this).animate({"left": "-3"},  "easeOut");
		$(this).animate({"left": "0"},  "easeOut");
	});


});	
		
$('.rightside h2, .full h2').animate({ "left": "0px"}, 1500,
										  
function(){
});	
		
		
$('.box,.boxlast').animate({ "top": "0"}, 3000,
										  
	function() {
		$(this).animate({"top": "10px"},  "ease");
		$(this).animate({"top": "0px"},  "ease");
});
		
$('#contact1').animate({ "top": "0"}, 1000,
										  
	function() {
		$(this).animate({"top": "0px"},  "ease");
		$(this).animate({"top": "0px"},  "ease");
});
		
$('#contact2').animate({ "top": "0"}, 1200,
										  
	function() {
		$(this).animate({"top": "0px"},  "ease");
		$(this).animate({"top": "0px"},  "ease");
});
		
$('#contact3').animate({ "top": "0"}, 1500,
										  
	function() {
		$(this).animate({"top": "0px"},  "ease");
		$(this).animate({"top": "0px"},  "ease");
});
		

	
$('#footer').animate({ "top": "0px"}, 3000,
										  
function(){
	$(".footermenu li a").hover(
	function() {
		$(this).animate({"top": "-5"},  "easeOut");
	},
	function() {
		$(this).animate({"top": "5"},  "easeOut");
		$(this).animate({"top": "0"},  "easeOut");
	});
		
});	

$('.myBox ').animate({ "top": "5px"}, 3000,
										  
function(){
	$(".socialized-in li a ").hover(
	function() {
		$(this).animate({"top": "0"},  "linear");
	},
	function() {
		$(this).animate({"top": "8"},  "linear");
		$(this).animate({"top": "5"},  "linear");
	});
		
});	

	
});
//news jcarausal
$(function() {
	$(".newsticker").jCarouselLite({
		vertical: true,
		hoverPause:true,
		visible: 2,
		auto:2000,
		speed:1000
	});
});

//rounded box
  $(function(){ 
  
  settings = {
          tl: { radius: 10 },
          tr: { radius: 10 },
          bl: { radius: 10 },
          br: { radius: 10 },
          antiAlias: true,
          autoPad: true,
          validTags: ["div"]
      }

  $('.myBox').corner(settings);
  
  });;


/* ========================================================== 
	(11) Image Tooltip
============================================================ */
/* Sticky Tooltip script (v1.0) 
* Author: Dynamic Drive at http://www.dynamicdrive.com/ 
* Visit http://www.dynamicdrive.com/ for full source code */

var stickytooltip={
	tooltipoffsets: [20, -30], //additional x and y offset from mouse cursor for tooltips
	fadeinspeed: 200, //duration of fade effect in milliseconds
	rightclickstick: false, //sticky tooltip when user right clicks over the triggering element (apart from pressing "s" key) ?
	stickybordercolors: ["black", "darkred"], //border color of tooltip depending on sticky state
	stickynotice1: ["Press \"s\"", "or right click", "to sticky box"], //customize tooltip status message
	stickynotice2: "Click outside this box to hide it", //customize tooltip status message

isdocked:false,positiontooltip:function($,$tooltip,e){var x=e.pageX+this.tooltipoffsets[0],y=e.pageY+this.tooltipoffsets[1]
var tipw=$tooltip.outerWidth(),tiph=$tooltip.outerHeight(),x=(x+tipw>$(document).scrollLeft()+$(window).width())?x-tipw-(stickytooltip.tooltipoffsets[0]*2):x
y=(y+tiph>$(document).scrollTop()+$(window).height())?$(document).scrollTop()+$(window).height()-tiph-10:y
$tooltip.css({left:x,top:y})},showbox:function($,$tooltip,e){$tooltip.fadeIn(this.fadeinspeed)
this.positiontooltip($,$tooltip,e)},hidebox:function($,$tooltip){if(!this.isdocked){$tooltip.stop(false,true).hide()
$tooltip.css({borderColor:'black'}).find('.stickystatus:eq(0)').css({background:this.stickybordercolors[0]}).html(this.stickynotice1)}},docktooltip:function($,$tooltip,e){this.isdocked=true
$tooltip.css({borderColor:'darkred'}).find('.stickystatus:eq(0)').css({background:this.stickybordercolors[1]}).html(this.stickynotice2)},init:function(targetselector,tipid){jQuery(document).ready(function($){var $targets=$(targetselector)
var $tooltip=$('#'+tipid).appendTo(document.body)
if($targets.length==0)
return
var $alltips=$tooltip.find('div.atip')
if(!stickytooltip.rightclickstick)
stickytooltip.stickynotice1[1]=''
stickytooltip.stickynotice1=stickytooltip.stickynotice1.join(' ')
stickytooltip.hidebox($,$tooltip)
$targets.bind('mouseenter',function(e){$alltips.hide().filter('#'+$(this).attr('rev')).show()
stickytooltip.showbox($,$tooltip,e)})
$targets.bind('mouseleave',function(e){stickytooltip.hidebox($,$tooltip)})
$targets.bind('mousemove',function(e){if(!stickytooltip.isdocked){stickytooltip.positiontooltip($,$tooltip,e)}})
$tooltip.bind("mouseenter",function(){stickytooltip.hidebox($,$tooltip)})
$tooltip.bind("click",function(e){e.stopPropagation()})
$(this).bind("click",function(e){if(e.button==0){stickytooltip.isdocked=false
stickytooltip.hidebox($,$tooltip)}})
$(this).bind("contextmenu",function(e){if(stickytooltip.rightclickstick&&$(e.target).parents().andSelf().filter(targetselector).length==1){stickytooltip.docktooltip($,$tooltip,e)
return false}})
$(this).bind('keypress',function(e){var keyunicode=e.charCode||e.keyCode
if(keyunicode==115){stickytooltip.docktooltip($,$tooltip,e)}})})}}
stickytooltip.init("*[rev]","mystickytooltip")


//Image Rotater

$(function() {		   
             setInterval("rotateImages()", 3000);
	      });
	
	     function rotateImages() {
				var oCurPhoto = $("#photoShow div.current");
				var oNxtPhoto = oCurPhoto.next();
				
				if (oNxtPhoto.length == 0)
					oNxtPhoto = $("#photoShow div:first");
					
				oCurPhoto.removeClass("current").addClass("previous");
				oNxtPhoto.css({opacity:0.0}).addClass("current").animate({opacity:1.0}, 1000, 
																		 function() {
																			 oCurPhoto.removeClass("previous");
																			 });
			}

