$(function(){

	//ajax json data for stock ticker

	if ($("#stock table").length == 1)
{
	var url = 'http://www.google.com/finance/info?infotype=infoquoteall&q=SHMN,^DJI,^IXIC,^BSESN,^SPX,^FTSE&callback=?';
    $.getJSON(url, function(data) { 
        var items = [];
        $.each(data, function(key, datum) {
			items.push("<tr>");
            items.push("<td>" + datum.name + "</td>");
            items.push("<td>" + datum.l + "</td>");
            items.push("<td>" + datum.c + "</td>");
			items.push("</tr>");
        });
        $("#stock table").html(items.join(""));
		$('#stock table tr td:contains("Industrial Average")').html($('#stock table tr td:contains("Industrial Average")').html().replace("Industrial Average", ""));
		$('#stock table tr td:contains("Composite")').html($('#stock table tr td:contains("Composite")').html().replace("Composite", ""));
		$('#stock table tr td:contains("SOHM INC")').html("<a href='http://www.otcmarkets.com/stock/SHMN/quote' target='_blank'>SOHM INC</a>");
		
		$('#stock table tr td:contains("-")').css({ "color" : "#990000" });
		$('#stock table tr td:contains("+")').css({ "color" : "#006600" });
		
		$("#stock table tr:odd").addClass('alt');
		$("#stock table tr td:nth-child(1), #stock table tr td:nth-child(4), #stock table tr td:nth-child(7), #stock table tr td:nth-child(10), ").css({ "padding-left" : "10px" });
		$('#stock table tr').click(function(){
			$('#stock table tr').removeClass('activeClass');
			$(this).addClass('activeClass');
		});
		
    });
}
	
	//detect chrome for a css fix
	$.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase()); 

	if($.browser.chrome){
		$('ul.menu li').css({ "padding-bottom" : "10px" });
	
	}
	
	
	
	
	//website slider
	$('#slider_images ul li').hide();
	$('#slider_images ul li:first').show();
	$('#slider_nav li:first').addClass('current').stop().css({ background: 'white', cursor: 'default' }).animate({ paddingLeft: "10px" }, 300);
	$('#slider_nav ul li:last-child').css({ border: 'none'});

	// Generate IDs for thumb and images LI

	var i = 1;
	var i2 = 1;
	var i3 = 1;

	$('#slider_nav ul li').each(function() {
		$(this).attr('id', 'myThumb_'+i); i++;
	});

	$('#slider_images ul li').each(function() {
		$(this).attr('id', 'myImg_'+i2); i2++;
	});

	// Image animation
	$('#slider_images img').hover(function(){
		$(this).stop().animate({ opacity: .9 }, 250);
	}, function(){
	    $(this).stop().animate({ opacity: 1 }, 350);
	});

	$('#myThumb_1').click(function(){
		if($(this).attr('class') != 'current') {
			$('#slider_images ul li').fadeOut();
			$('#myImg_1').fadeIn();
		}
	});

	$('#myThumb_2').click(function(){
		if($(this).attr('class') != 'current') {
			$('#slider_images ul li').fadeOut();
			$('#myImg_2').fadeIn();
		}
	});

	$('#myThumb_3').click(function(){
		if($(this).attr('class') != 'current') {
			$('#slider_images ul li').fadeOut();
			$('#myImg_3').fadeIn();
		}
	});
	
	$('#myThumb_4').click(function(){
		if($(this).attr('class') != 'current') {
			$('#slider_images ul li').fadeOut();
			$('#myImg_4').fadeIn();
		}
	});

	// Navigation animation
	$('#slider_nav li').click(function(){
		$(this).stop().css({ background: 'white', cursor: 'default' }).animate({ paddingLeft: "10px" }, 300);
		if($(this).attr('class') != 'current') {
			$('.current').stop().css({ background: 'none', cursor: 'pointer' }).animate({ paddingLeft: "1px" }, 150);
			$('.current').removeClass('current');
		}
		$(this).addClass('current');
	});

	$('#slider_nav li').hover(function(){
		if($(this).attr('class') != 'current') {
			$(this).stop().animate({ paddingLeft: "10px" }, 300);
		}
	}, function(){
		if($(this).attr('class') != 'current') {
			$(this).stop().animate({ paddingLeft: "1px" }, 150);
		}
	});

	
	//ajax loads of careers;
	$('#india').click(function(){
		$('#careers').load('http://www.sohm.com/careers/india/ #ajaxLoad');
		$('#countryFilter li').removeClass('active');
		$(this).addClass('active');
		
	});
	$('#unitedStates').click(function(){
		$('#careers').load('http://www.sohm.com/careers/united-states/ #ajaxLoad');
		$('#countryFilter li').removeClass('active');
		$(this).addClass('active');
	});
	$('#unitedKingdom').click(function(){
		$('#careers').load('http://www.sohm.com/careers/united-kingdom/ #ajaxLoad');
		$('#countryFilter li').removeClass('active');
		$(this).addClass('active');
	});
	$('#china').click(function(){
		$('#careers').load('http://www.sohm.com/careers/china/ #ajaxLoad');
		$('#countryFilter li').removeClass('active');
		$(this).addClass('active');
	});
	$('#global').click(function(){
		$('#careers').load('http://www.sohm.com/careers/global/ #ajaxLoad');
		$('#countryFilter li').removeClass('active');
		$(this).addClass('active');
	});
	
	//product styles via jQuery
	$('#content table tr:odd').addClass('alt');
	$('#content table tr td:nth-child(1), #content table tr td:nth-child(4), #content table tr td:nth-child(5)').css( { "text-align" : "center" } );
	$('#content table tr td:nth-child(1)').css( { "padding" : "0 20px" } );
	$('#content table tr th:nth-child(1), #content table tr th:nth-child(4), #content table tr th:nth-child(5)').css( { "text-align" : "center" } );
	
	$('#content table tr').click(function(){
		$('#content table tr').removeClass('activeClass');
		$(this).addClass('activeClass');
	});
	
});

