

$(document).ready(function(){
	
	
	//set current page to current class in navigation
	var path = location.pathname;  
	var paths = new Array;
	paths = path.split("/");
	path = paths[paths.length-1];
	//path = path.replace(new RegExp(/^\//i),"");
	if (path == "") {path = "index.php"};
    $("a[href $='" + path + "']").parents("li").each(function() {
        $(this).addClass("current");
    });

	//toggle answers on FAQ
	$(".faq-q").click(function(){
		$(this).parent().parent().children(".faq-a").slideToggle("slow"); 
		
		return false;
	});
	
	//info bubbles
	$(' .ct-services span ').hide(); 
	
	$(".ct-services").hover(function(){
		$(this).children().children('span').show();
		return false;
	}, function(){

		$(this).children().children('span').hide();
		return false;
	});
	
	// tabbed box for newsfeed

    $(".tabbed-box .tabs li a").click(function() {
        openTab($(this)); return false;
    });

    $(".tabbed-box .tabs li a:eq("+currentTab+")").click();
	
	
	//contact us for more infrormation phone or email
		if ($("input[name='how_contact']:checked").val() == "Email"){
			$('#show-if-phone').hide();
			$('#show-if-email').show();
		}
		else {
			$('#show-if-phone').show();
		    $('#show-if-email').hide();
		};

	$("input[name='how_contact']").change(
	function()
	{
		if ($("input[name='how_contact']:checked").val() == "Email"){
			$('#show-if-phone').hide();
			$('#show-if-email').show();
			$('#email').addClass('required');
			$('#confirm_email').addClass('required');
		}
		else {
			$('#show-if-phone').show();
		    $('#show-if-email').hide();
			$('#phone').addClass('required');
			$('#availabilty').addClass('required');
		};
		$(this).blur();
	}
	);

	
	
	//validate contact us form
	 /*   $("#contact-us-form").validate({
									   
			rules: {
					email: {
					  email: "true"
					},
					confirm_email: {
					  email: "true",
					  equalTo: "#email"
					},
					phone: {
						minlength: 2
					}
			  }
		});*/


	
	   
	
	
});


function setHome()
  {
    if (document.all)
    {
     document.body.style.behavior='url(#default#homepage)';
     document.body.setHomePage('http://integrity.com/home/home.php');

    }
    else if (window.sidebar)
     {
         
	var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage','http://url_of_page.com');
}
}

var currentTab = 0; 

function openTab(clickedTab) {
    var thisTab = $(".tabbed-box .tabs a").index(clickedTab);
    $(".tabbed-box .tabs li a").removeClass("active");
	$(".tabbed-box .tabs li").removeClass("current");
    $(".tabbed-box .tabs li a:eq("+thisTab+")").addClass("active");
	$(".tabbed-box .tabs li:eq("+thisTab+")").addClass("current");
    $(".tabbed-box .tabbed-content").hide();
    $(".tabbed-box .tabbed-content:eq("+thisTab+")").show();
    currentTab = thisTab;
}


//set and get cookies
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}


// check and change zip cookie
function checkZipCookie()
{
zip=getCookie('zip');
if (zip!=null && zip!="")
  {
	document.write("<a href='#' onclick='changeZip();'>Change Your Location</a>");
  }
else
  {
  document.write("<a href='#' onclick='changeZip();'>Customize Your Homepage</a>");
  }
}

function changeZip()
{
zip = prompt('Please enter your zip code:',"");
if (zip!=null && zip!="")
    {
    setCookie('zip',zip,365);
    }
	window.location.reload();
}

function getZipCookie(){
	zip = getCookie('zip');
	if (zip!=null && zip!="")
  	{
		return zip;
  	}
	else
	{
	  	return "35801";
	}
	
}

function getWeatherObject(){
	document.write("<object title='weather' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='184' height='76' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='http://www.weatherlet.com/weather.swf?locid=" + getZipCookie() + "&unit=s'/><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed title='weather' src=http://www.weatherlet.com/weather.swf?locid=" + getZipCookie() + "&unit=' quality='high' wmode='transparent' bgcolor='#CC00CC' width='200' height='85' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>");
}