$(document).ready(function () {
		
		var toolTipOn = false;
 		var URL = 'http://www.generationone.com/';
 		
 		
 		
 		// initial settings
		$("#overview-menu").css("margin-top","27px");
 		$("#overview-menu").css("left","70px");
		$(".submenu").css("margin-top","27px");
 		$(".submenu").css("left","168px");
 		
 		// make dropdown opaque
 		$(".submenu").css("opacity",".9");
 		$(".submenu").animate({opacity:.9},"fast");
 		
 		
 		// hide last line breaking image on drop downs
 		$(".submenu").each(function(){
 			$("a:last", this).css("background", "none");
 		});
 		$("#news #col2").each(function(){
 			$("p:last", this).css("border", "0");
 		});
 		
  	// hack to make IE6 acceppt the dropdowns	
    if (document.all) {
        $("#global-nav li").hoverClass ("sfHover");
    }
		
		$('.active').click(function(){return false;});
		
		// make link not do anything
		$("#solutions-link").click(function(){return false;});
		
		
		if(document.body.id.value == "home" || document.body.id == "home"){
			
			var theurl = window.location;
			theurl = String(theurl);
			if(theurl.indexOf("?consumers") != -1){		
				$("#consumers-menu").show();
				$("#employers-menu").hide();
				$("#heatlhcare-menu").hide();
			}else if(theurl.indexOf("?employers") != -1){		
				$("#consumers-menu").hide();
				$("#employers-menu").show();
				$("#heatlhcare-menu").hide();
			}else if(theurl.indexOf("?healthcare") != -1){		
				$("#consumers-menu").hide();
				$("#employers-menu").hide();
				$("#heatlhcare-menu").show();
			}else{
				$("#main-tabs #consumers").addClass("active");
				$("#consumers-menu").show();
				$("#employers-menu").hide();
				$("#heatlhcare-menu").hide();
			}
			
		
		/*

 		$("#consumers-menu").show();
 		$("#employers-menu").hide();
 		$("#heatlhcare-menu").hide();
*/
		
			$('#main-tabs #consumers').mouseover(function () {
				$("#tooltip1").fadeIn("slow");				 
				$("#tooltip2").hide();
				$("#tooltip3").hide();
				toolTipOn = true;
			}).mouseout(function () {
				$("#tooltip1").hide();
			});
			$('#main-tabs #employers').mouseover(function () {
				$("#tooltip2").fadeIn("slow");
				$("#tooltip3").hide();
				$("#tooltip1").hide();
				toolTipOn = true;
			}).mouseout(function () {
				$("#tooltip2").hide();
			});
			
			$('#main-tabs #healthcare').mouseover(function () {
				$("#tooltip3").fadeIn("slow");
				$("#tooltip2").hide();
				$("#tooltip1").hide();
				toolTipOn = true;
			}).mouseout(function () {
				$("#tooltip3").hide();
			});
		}
		
		// on click of consumers tab
		$('#main-tabs #consumers').click(function () {
			
			// set overview link
			$('#overview-link').attr({href: URL +"index.php/overview/?consumers"});
			$('#solutions-link').attr({href: URL +"our-solutions.php?consumers"});
			
			// change banner
			$("#banner-wrap").removeClass("employers");
			$("#banner-wrap").removeClass("healthcare");
			$("#banner-wrap").addClass("consumers");
			
			// set class on h2 of col3 to change background image
			$("#col3 h2").removeClass("employers");
			$("#col3 h2").removeClass("healthcare");
			$("#col3 h2").addClass("consumers");
			
			// set status on tabs
			$("#main-tabs #consumers").addClass("active");
			$("#main-tabs #employers").removeClass("active");
			$("#main-tabs #healthcare").removeClass("active");
			
      $("#consumers-menu").show();
			
			if(document.body.id.value == "home" || document.body.id == "home"){

				// change submenus
				
				$("#employers-menu").hide();
				$("#heatlhcare-menu").hide();
				$("#consumers-menu").show();
				
				$("#col1").html("<h2>Take charge of your health</h2><p>Our flexible, easy-to-use mobile health program is designed to enhance your life with up-to-the minute monitoring, reminders, alerts and support delivered through your mobile phone. It's the ideal solution for everyone, from kids to seniors, to stay in touch with caregivers and doctors. You can choose to use phones provided by GenerationOne or link to these services through your own compatible mobile phone.</p><p>GenerationOne is dedicated to improving your health and our new 24-hour mobile solution enables you to take control and stay connected.</p>");
				$('#col2').html('<h2><a href="'+URL+'index.php/your-health-solution-consumers/" title="Learn more about: Our Condition & Wellness support">Learn more about: <span>Our Condition & Wellness support</span></a></h2><ul><li><span>Diabetes</span></li><li><span>Congestive Heart Failure</span></li><li><span>Asthma</span></li><li><span>Obesity</span></li><li><span>Health and wellness</span></li></ul>');
				$("#col3").html('<h2 class="consumers"><a href="'+URL+'index.php/real-life-solutions-consumers/" title="Real-Life Solutions">Real-Life Solutions</a></h2><div id=col3img><img src="/i/consumerh2.jpg" height="146" width="248"></div><p>See stories about how GenerationOne is helping people take charge of their health.</p><p><a href="'+URL+'index.php/real-life-solutions-consumers/" title="Learn More">Learn More</a></p>');
				
				return false;
			}
		});    
		
		$('#main-tabs #employers').click(function () {
		
			
			// set employer link
			$('#overview-link').attr({href: URL +"index.php/overview/?employers"});
			$('#solutions-link').attr({href: URL +"our-solutions.php?employers"});
			
			$("#banner-wrap").removeClass("consumers");
			$("#banner-wrap").removeClass("healthcare");
			$("#banner-wrap").addClass("employers");
			
			$("#col3 h2").removeClass("consumers");
			$("#col3 h2").removeClass("healthcare");
			$("#col3 h2").addClass("employers");
			
			$("#main-tabs #employers").addClass("active");
			$("#main-tabs #consumers").removeClass("active");
			$("#main-tabs #healthcare").removeClass("active");
			
			if(document.body.id.value == "home" || document.body.id == "home"){
					
				$("#employers-menu").show();
				$("#heatlhcare-menu").hide();
				$("#consumers-menu").hide();

				$("#col1").html("<h2>One solution. Many benefits.</h2><p>GenerationOne empowers patients with round-the-clock monitoring and support delivered through their mobile phones. Designed to reduce healthcare costs and improve efficiencies, our mobile health solution improves medication compliance, improves adherence to prescribed health regimens, and decreases emergencies and hospitalizations.</p><p>GenerationOne is dedicated to delivering solutions that help organizations drive efficiencies and manage healthcare costs by improving the health of individuals through better self-management.</p>");
				$("#col2").html('<h2>GenerationOne Mobile Health Solution</h2><ul class="icons"><li><a href="' + URL + 'index.php/end-to-end-solution-employers/" title="End-to-end solution">End-to-end solution <img src="i/icon_endtoend.jpg" width="50" height="50" alt="" /></a></li><li><a href="' + URL + 'index.php/mobile-phone-network-employers/" title="Mobile phone &amp; network">Mobile phone &amp; network<img src="i/icon_mobile.jpg" width="50" height="50" alt="" /></a></li><li><a href="' + URL + 'index.php/clinical-decision-support-employers/" title="Clinical decision support">Clinical decision support<img src="i/icon_clinical.jpg" width="50" height="50" alt="" /></a></li><li><a href="' + URL + 'index.php/flexible-technology-employers/" title="Flexible technology">Flexible technology<img src="i/icon_flexible.jpg" width="50" height="50" alt="" /></a></li></ul>');
				$("#col3").html('<h2 class="employers"><a href="' + URL + 'index.php/real-life-solutions-employers/" title="Real-Life Solutions">Real-Life Solutions</a></h2><div id=col3img><img src="/i/employersh2.jpg" width="248" height="146" alt="Real-life solutions" /></div><p>See stories about how GenerationOne is helping people take charge of their health.</p><p><a href="' + URL + 'index.php/real-life-solutions-employers/" title="Learn More">Learn More</a></p>');
				$("#content").fadeIn("slow");			
				return false;
			}
		});
		
		
		$('#main-tabs #healthcare').click(function () {
		
			// set overview link
			$('#overview-link').attr({href: URL +"index.php/overview/?healthcare"});
			$('#solutions-link').attr({href: URL +"our-solutions.php?healthcare"});
		
			$("#banner-wrap").removeClass("consumers");
			$("#banner-wrap").removeClass("employers");
			$("#banner-wrap").addClass("healthcare");
			
			$("#col3 h2").removeClass("consumers");
			$("#col3 h2").removeClass("employers");
			$("#col3 h2").addClass("healthcare");
			
			$("#main-tabs #healthcare").addClass("active");
			$("#main-tabs #consumers").removeClass("active");
			$("#main-tabs #employers").removeClass("active");
			
			if(document.body.id.value == "home" || document.body.id == "home"){
				$("#col1").html("<h2>A breakthrough in 24/7 support</h2><p>Health professionals are the key to successful collaborative care, and now you have a tool to get an accurate and up-to-the-minute view of your patients. Easy to adopt, integrate and use, this new 24/7 mobile technology can detect critical signals before a crisis begins, and notify patients and caregivers through pre-defined triggers., The result is the ability to  monitor, guide, inform, and intervene with patients wherever and whenever necessary.</p><p>GenerationOne is dedicated to better health and that means arming you with a new level of support to make your job easier and more effective.</p>");
				$("#col2").html('<h2>GenerationOne Mobile Health Solution</h2><ul><li><a href="' + URL + 'index.php/your-solution-healthcare-professionals/" title="Your solution for collaborative care">Your solution for <br />collaborative care</a></li></ul>');
			
				$("#col3").html('<h2 class="healthcare"><a href="' + URL + 'index.php/real-life-solutions-healthcare-professionals/" title="Real-Life Solutions">Real-Life Solutions</a></h2><div id=col3img><img src="/i/healthcareh2.jpg" width="248" height="146" alt="Real-Life Solutions" /></div><p>See stories about how GenerationOne is helping people take charge of their health.</p><p><a href="' + URL + 'index.php/real-life-solutions-healthcare-professionals/" title="Learn More">Learn More</a></p>');
				$("#employers-menu").hide();
				$("#heatlhcare-menu").show();
				$("#consumers-menu").hide();
				return false;
			}
		});
	
});



// Functions

$.fn.hoverClass = function(c) {
    return this.each(function(){
        $(this).hover( 
            function() { $(this).addClass(c);  },
            function() { $(this).removeClass(c);  }
        );
    });
};
