/*
CSS Browser Selector v0.3.5 (Feb 05, 2010)
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',o='opera',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; 

var browser_type;

jQuery(document).ready(function(){
						   
	browser_type = css_browser_selector(navigator.userAgent);
	if(browser_type.indexOf('ie6') > -1) {
		// ie6 only scripts

    } 

	jQuery(".gcltt_link").gcltooltip();

});



(function($) {
$.fn.gcltooltip = function(options) {
	
	var defaults = {
		disableLink : true,
		onOver      : ""
	},
	settings = $.extend({}, defaults, options);
	
	//console.log("$(window).height(): %d  |  $(document).height(): %d  | $(window).innerHeight(): %d  | $(document).innerHeight(): %d  ", $(window).height(), $(document).height(), $(window).height(), $(document).height()); 
		
	return this.each(function() {
		var $this = jQuery(this),
		gclttwh = new Array(), gclttposlt = new Array(), gcldocwh  = new Array(), position,
		$tt = jQuery("#" + $this.attr("id") + "_tt"),
		isOverTT = 0;		

		$tt.wrapInner('<div class="gcltt_content" />');
		gclttwh[0]=$tt.outerWidth();
		gclttwh[1]=$tt.outerHeight();


		function calculatePos() {
			position = $this.position();
			gcldocwh = [$(window).width(), $(window).height()];
			
			//$(document).scrollLeft();
			//$(document).scrollTop();
/*
			if (window.console && window.console.firebug) {
				console.log("----------------------------------");
				console.log("gcldocw: %d | gcldoch: %d", gcldocwh[0], gcldocwh[1]);
				console.log("gclttw: %d | gcltth: %d", gclttwh[0], gclttwh[1]);
				console.log("position.left: %d | position.top: %d", position.left, position.top);
				
				console.log("$(document).scrollLeft(): %d | $(document).scrollTop(): %d", $(document).scrollLeft(), $(document).scrollTop());
				console.log("$(window).scrollLeft(): %d | $(window).scrollTop(): %d", $(window).scrollLeft(), $(window).scrollTop());
				
				console.log("gcldocwh[0]: %d - position.left: %d - gclttwh[0]: %d  = %d", gcldocwh[0], position.left, gclttwh[0], (gcldocwh[0] - position.left - gclttwh[0]) );
				console.log("gcldocwh[1]: %d - position.top: %d - gclttwh[1]: %d  = %d", gcldocwh[1], position.top, gclttwh[1], (gcldocwh[1] - position.top - gclttwh[1]) );
			}
*/
			//TODO: consider scrollLeft and scrollTop  values when calculating tooltip pos.
			
		
			// left / right of link
			if((gcldocwh[0] - position.left - gclttwh[0]) > 10 ) { 
				// show on the right
				gclttposlt[0] = position.left + ($this.width()/2)-3;
			} else { 
				// show on the left
				gclttposlt[0] = position.left - (gclttwh[0]) + ($this.width()/2);
			}	
			
			gclttposlt[1] = position.top - gclttwh[1];
			/*
			if((gcldocwh[1] - position.top - gclttwh[1]) > 10 ) { 
				// show on the bottom
				//console.log("bottom");
				gclttposlt[1] = position.top + $this.height();
			} else { 
				// show on the top
				//console.log("top");
				gclttposlt[1] = position.top - gclttwh[1];
			}
			*/
			
			$tt.css({ top:gclttposlt[1], left:gclttposlt[0] });
		}

					
		if(settings.disableLink) {
			$this.attr({'href': 'javascript:void(0)'});
		}

		function showTT() {
			isOverTT++;
			if(isOverTT < 2) { 
				calculatePos(); 
				$tt.show(); 
			}
		}		
		function hideTT() {
			isOverTT--;
			if(isOverTT < 1) {
				isOverTT = 0;
				$tt.hide();
			}
		}
		
		$this.hoverIntent({    
			 sensitivity: 3,
			 interval: 100,
			 over: showTT, 
			 timeout: 500, 
			 out: hideTT
		});

		$tt.hoverIntent({    
			 sensitivity: 3,
			 interval: 10,
			 over: showTT, 
			 timeout: 500, 
			 out: hideTT
		});

		

	});
};
})(jQuery);







//////////////////////////////////////////////////////////////////////////////
// [JQuery CSS Image Replacement Plugin] //////////////////////////////////////
(function($) {
$.fn.cssir = function(options) {
	
	var defaults = {
		spanClassName :null,
		spanClassNameFromParent:null,
		onOver        : false,
		onOverSuffix  : "_oo"
	},
  settings = $.extend({}, defaults, options);
	
	return this.each(function() {
		var $this = $(this),
		$span, className;
		
		if(settings.spanClassName != null && settings.spanClassName != "") {
			className = settings.spanClassName;
		} else if(settings.spanClassNameFromParent != null && settings.spanClassNameFromParent != "") {
			className = $this.parents(settings.spanClassNameFromParent).attr("id") + "_span";
		} else {
			className = $this.attr("id") + "_span"; //$("#debug").append("<br />" + className);
		}
		
		$span = $('<span class="'+className+'"> </span>'); //$span = $(document.createElement("span"));
		$this.append($span);
		if(settings.onOver) {
			$this.hover(function () {
				$span.removeClass(className).addClass(className+settings.onOverSuffix);
			},function () {
				$span.removeClass(className+settings.onOverSuffix).addClass(className);
			});			
		}

	});
};
})(jQuery);




///////////////////////////////////////////////////////////////////////////////
// [JQuery Top Slider Plugin] /////////////////////////////////////////////////
(function($) {
$.fn.gcltopslider = function(options) {
	
	var defaults = {
		slideSpeed        : 400,  // How quickly should the panels scroll?
		activeClass       : "active_top_slide_link",
		contentClass      : "top_slide_panel"
	},
    settings = $.extend({}, defaults, options),
	$topSlideLinks, $topSlidePanels, topSlidePanelCurPos = -1;
	
	$topSlideLinks = $(this).find("li a");
	$topSlidePanels = $("."+settings.contentClass);
	
	function toggleTopSlidePanel() {
		$topSlidePanels.not(':eq('+topSlidePanelCurPos+')').slideUp(settings.slideSpeed);
		$topSlidePanels.eq(topSlidePanelCurPos).slideToggle(settings.slideSpeed);
		$topSlideLinks.not(':eq('+topSlidePanelCurPos+')').removeClass(settings.activeClass);
		$topSlideLinks.eq(topSlidePanelCurPos).toggleClass(settings.activeClass);
	}
	
	$topSlideLinks.attr({'href': 'javascript:void(0)'}).click(function () {
      	topSlidePanelCurPos = $topSlideLinks.index(this);
		toggleTopSlidePanel();
	});
																		
	// returns the jQuery object to allow for chainability.  
    return this;
};
})(jQuery);




///////////////////////////////////////////////////////////////////////////////
// [JQuery Accordion Plugin] //////////////////////////////////////////////////
(function($) {
$.fn.gclaccordion = function(options) {
	
	var defaults = {
		slideSpeed        : 400,  // How quickly should the accordion scroll?
		hideActiveLink    : true, // Hide clicked link?
		activeClass       : "active_header", //
		contentClass      : "accordionContent", //Content divs class name
		openContentOnLoad : -1,   //If -1, all tabs will be closed on load, else open content at given pos
		onOverSuffix: "_oo"
	},
    settings = $.extend({}, defaults, options),
	$this = $(this),
	$accordionlinks, $accordioncontents;
	
	$accordionlinks = $this.find("h3 a");
	$accordioncontents = $this.find("."+settings.contentClass);
	
	$accordioncontents.hide();

	if(settings.openContentOnLoad > -1) {
		if(settings.activeClass != null && settings.activeClass != "") {
			$accordionlinks.eq(settings.openContentOnLoad).addClass(settings.activeClass);
		}
		if(settings.hideActiveLink) {
			$accordionlinks.eq(settings.openContentOnLoad).hide();
		}
		$accordioncontents.eq(settings.openContentOnLoad).show();
	}
	
	$accordionlinks.attr({'href': 'javascript:void(0)'}).click(function(){
		$accordionlinks.show("fast"); 
		if(settings.hideActiveLink) {
			$(this).animate({opacity: "hide"}, 500);  
		}
		if(settings.activeClass != null && settings.activeClass != "") {
			$(this).addClass(settings.activeClass)
		}
		//$(this).parent().siblings("div:visible").slideUp();
		//$(this).parent().next("div").slideDown();
		$(this).parent().next("div").slideToggle(settings.slideSpeed).siblings("div:visible").slideUp(settings.slideSpeed);
	});


	// returns the jQuery object to allow for chainability.  
    return this;
	
};
})(jQuery);



///////////////////////////////////////////////////////////////////////////////
// [JQuery Horizontal Slide Plugin] ///////////////////////////////////////////
(function($) {
$.fn.hslide = function(options) {
	
	var defaults = {
		previousLinkID: "slide-previous-link",
		nextLinkID    : "slide-next-link",
		slideLinksID  : 'slideLinks',
		slideItemWidth: 867,
		slideDelay    : 5000,  // How long a rest between transitions?
		slideSpeed    : 1500,  // How quickly should the items scroll?
		slideOnLoad   : true
	},
    settings = $.extend({}, defaults, options),
	$this = $(this),
	slideCurPos = 0, slideItemCount, slideInterval, $slideLinks, $slideItems;
	
	$slideLinks = $("#"+settings.slideLinksID+" li");
	$slideItems = $this.find("li");   
	$("#"+settings.slideLinksID+" a").attr({ 'href': 'javascript:void(0)' });  
	slideItemCount = $slideItems.size(); 
	
	if(settings.slideOnLoad) {
		slideTo();                                                               
		slideInterval = setInterval(slideToNext, settings.slideDelay);
	} else { 
		slideTo(); 
	}                     
                                                                               
	$("#"+settings.previousLinkID).attr({ 'href': 'javascript:void(0)' }).click(function() { slideToPrevious(); });      
	$("#"+settings.nextLinkID).attr({ 'href': 'javascript:void(0)' }).click(function() { slideToNext(); });              
                                                              
	$slideLinks.click(function() {                                           
        if (slideCurPos != $slideLinks.index(this)){                             
          clearInterval(slideInterval);                                        
          slideCurPos = $slideLinks.index(this);                               
          slideTo();
		  if(settings.slideOnLoad) { slideInterval = setInterval(slideToNext, settings.slideDelay); }
        }                                                                      
	});                                                                      
                                                                               
	function slideToPrevious() {                                             
	  clearInterval(slideInterval);                                        
	  slideCurPos--;                                                       
	  if (slideCurPos < 0) { slideCurPos = slideItemCount - 1; }           
	  slideTo();                                                           
	  if(settings.slideOnLoad) { slideInterval = setInterval(slideToNext, settings.slideDelay); }
	}                                                         
                                                                               
	function slideToNext() {                                                 
	  clearInterval(slideInterval);                                        
	  slideCurPos++;                                                       
	  if (slideCurPos >= slideItemCount) { slideCurPos = 0; }              
	  slideTo();                                                           
	  if(settings.slideOnLoad) { slideInterval = setInterval(slideToNext, settings.slideDelay); }             
	}                                               
                                                                               
	function slideTo() {                                                                                         
	  $slideLinks.find("a").show();                                        
	  $slideLinks.eq(slideCurPos).find("a").hide();                        
	  var slideTo = (slideCurPos * settings.slideItemWidth);                        
	  $this.animate({ marginLeft: "-" + slideTo + "px" }, settings.slideSpeed);
	}
	  

	// returns the jQuery object to allow for chainability.  
    return this; 
	 
};
})(jQuery);




///////////////////////////////////////////////////////////////////////////////
// [JQuery Vertical Slide Plugin] /////////////////////////////////////////////
(function($) {
$.fn.vslide = function(options) {
	
	var defaults = {
		slideLinksID: 'vSlideLinks'
	},
    settings = $.extend({}, defaults, options),
	$this = $(this),
	slideCurPos = -1, slideInterval, $slideLinks, $slideItems;
	
	$slideLinks = $("#"+settings.slideLinksID+" li a");
	$slideItems = $this.find("li");
  
	$slideLinks.attr({'href': 'javascript:void(0)'}).eq(0).hide();
	$slideItems.slice(1).hide();

	//if ($.browser.msie) { gclContentRotatorLinkHeight += 2; }
  
	$slideLinks.click(function () { 
		if(slideCurPos != $slideLinks.index(this)) {
			slideCurPos = $slideLinks.index(this);
			//$("#gcl-content-rotator-arrow").animate({ top:(gclContentRotatorLinkCurPos*gclContentRotatorLinkHeight)+gclContentRotatorLinkTop }, "fast");
			$slideLinks.animate( {opacity: "show"}, 500);
			$(this).animate({opacity: "hide"}, 50);
			$slideItems.hide().eq(slideCurPos).fadeIn("slow");
		}
	});
	
	// returns the jQuery object to allow for chainability.  
    return this; 

};

})(jQuery);








///////////////////////////////////////////////////////////////////////////////
// [JQuery gclslide Plugin] //////////////////////////////////////
(function($) {
$.fn.gclslide = function() {
  return this.each(function() {
    var $this = $(this),
    wrapperId, $close, $content, contentContent = null, isDivVisible = false;
		
    wrapperId = $this.attr("onclick").toString()+ " ";
	if(wrapperId.indexOf("'") > 0) { wrapperId = wrapperId.split("'")[1]; }
	else if(wrapperId.indexOf("\"") > 0) { wrapperId = wrapperId.split("\"")[1]; } 
	else { return false; }

	$close   = $("#"+wrapperId+" > .glacialslide-move > .control");
	$content = $("#"+wrapperId+" > .glacialslide-body");
	
	contentContent = '<OBJECT id="Cataract Surgery" classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width=402 height=400><PARAM NAME="_cx" VALUE="10636"><PARAM NAME="_cy" VALUE="10583"><PARAM NAME="FlashVars" VALUE="aID=66210b72ebbdb14120c2c7430eb7df83"><PARAM NAME="Movie" VALUE="http://eyemaginations.com/3deyeonline/3deonlinev20.swf"><PARAM NAME="Src" VALUE="http://eyemaginations.com/3deyeonline/3deonlinev20.swf"><PARAM NAME="WMode" VALUE="Transparent"><PARAM NAME="Play" VALUE="0"><PARAM NAME="Loop" VALUE="-1"><PARAM NAME="Quality" VALUE="High"><PARAM NAME="SAlign" VALUE=""><PARAM NAME="Menu" VALUE="-1"><PARAM NAME="Base" VALUE=""><PARAM NAME="AllowScriptAccess" VALUE=""><PARAM NAME="Scale" VALUE="ShowAll"><PARAM NAME="DeviceFont" VALUE="0"><PARAM NAME="EmbedMovie" VALUE="0"><PARAM NAME="BGColor" VALUE="FFFFFF"><PARAM NAME="SWRemote" VALUE=""><PARAM NAME="MovieData" VALUE=""><PARAM NAME="SeamlessTabbing" VALUE="1"><PARAM NAME="Profile" VALUE="0"><PARAM NAME="ProfileAddress" VALUE=""><PARAM NAME="ProfilePort" VALUE="0"><PARAM NAME="AllowNetworking" VALUE="all"><PARAM NAME="AllowFullScreen" VALUE="false"><embed type="application/x-shockwave-flash" src="http://eyemaginations.com/3deyeonline/3deonlinev20.swf" style="" id="Cataract Surgery" name="Cataract Surgery" bgcolor="#FFFFFF" quality="high" wmode="transparent" flashvars="aID=66210b72ebbdb14120c2c7430eb7df83" height="400" width="402"></embed></OBJECT>';
	
	$close.click(function () { 
	  if(null == contentContent) { contentContent = $content.html(); alert(contentContent); }
	  $content.html("");
    });
 
    $this.click(function () { 
	  if(null != contentContent) { $content.html(contentContent); }
    });
	
  });
};
})(jQuery);




(function($) {
$.fn.overlabel = function(options) {
  this.each(function() {
    var $this = $(this), label = $this.attr("title"), input_val;
	$this.focus(function () {
		input_val = $this.val();
		if(label == input_val){
			$this.val("").focus();
		}
    })
	.blur(function () {
		if("" == $this.val()){
			$this.val(label);
		}
    });
  });
};
})(jQuery);
