//$(function(){
//jQuery.noConflict();
// JavaScript Documentwindow.onload = function() {
jQuery(document).ready(function($){

	//onLoad/Show
	$('#banner').show();
	$('body#home #left #box').show();
	$('#menu').show();

	//Add 'selected' classes to menu and submenu items
	var URL = location.href.substring(location.href.lastIndexOf('/') + 0);//+location.hash;
		if ( URL ) {
			$('#menu a[href$="' + URL + '"]').parent('li').addClass('selected');
	}	
	
	//Add banners to pages
	/*var url = window.location.pathname;
	  if (url.indexOf("/about") > -1) {
		$("#left").prepend('<div id="banner"><img src="/images/banners/banner_about.jpg" width="584px" height="328px" border="0" /></div>');
	  }
	  else if (url.indexOf("/contact") > -1) {
		$("#left").prepend('<div id="banner"><img src="/images/banners/banner_contact.jpg" width="584px" height="328px" border="0" /></div>');
	  }
	  else if (url.indexOf("/support") > -1) {
		$("#left").prepend('<div id="banner"><img src="/images/banners/banner_support.jpg" width="584px" height="328px" border="0" /></div>');
	  }*/
	  	  

	//Single Toggle
	$('.expander').each(function(){
		if( !$(this).parent().hasClass('current') ) {
				$(this).parent().css('height',$(this).outerHeight());
			}
		});
	
	var partnerGroups = $('ul').children();
		
	partnerGroups.find('.expander').click(function($e){
		$e.preventDefault();
		var pg = $(this).closest('li');
		if(pg.hasClass('current'))//If this is the current item
		{
			pg.animate({height: pg.find('.expander').outerHeight()},200,'swing').removeClass('current');		
		} else {
			$('ul').find('.current').animate({height: pg.find('.expander').outerHeight()},200,'swing').removeClass('current');	
			pg.animate({height: Math.round(pg.find('.expander').outerHeight() + pg.find('.innerContent').outerHeight())},200,'swing').addClass('current');
		}
	});

	//Open first accordion LI
	$('ul.accordion.news').find('li:first').animate({height: Math.round($('li').find('.expander').outerHeight() + $('li').find('.innerContent').outerHeight())},200,'swing').addClass('current');	


	//Multiple Toggle
//	$('.expander').next('.innerContent').hide();
	//$('.expander:first').next('.innerContent').show();
//	$('.expander').click(function() {
//		$(this).toggleClass('expanded').next('.innerContent').slideToggle();
//		$(this).parent('li').toggleClass('current');
//		return false;
//	});


	//Toggle Open / Close Buttons on FAQs Page	
	$(".faq-question a").click (function() {
		$(this).parent(".faq-question").toggleClass("close");
		return false;
	});
	//Remove bottom border from last sections	
	$("ul.accordion li:last").css('border-bottom','0px');
	$(".faq-question:last").css('border-bottom','0px');


	//Remove bottom border from last Question	
	$("#top_info marquee").hover( function() {
		$(this).attr('scrollamount','1');
	},
	function () {
		$(this).attr('scrollamount','3');
	});


	//Horzontal Rules
	$('hr').css('display','none').css('visibility','hidden').wrap('<div class="hr"></div>');


//Add rounded corners to images
	//Loop through all the img in a specified area.
	$('#banner img').each(function(index){
		
		//Check if image has "NoRoundCorner" class.
		if ($(this).hasClass('no_rounded') == false){
		
			//Get dimensions.
			var width = $(this).width();
			var height = $(this).height();
			
			//Remove Image Margin
			$(this).addClass('noMargin');
			
			//Add .overlay div before each image.
			$(this).after('<div class="overLay imgNum' + index + '" style="width:' + width + 'px; height:' + height + 'px"></div>');
			
			//Add corner divs to .overLay.
			$(this).prependTo('.imgNum' + index + '');
		}
	
	});
	
	//Add corner overlay divs.
	$('.overLay').append('<div class="cornerTopLeft"></div><div class="cornerTopRight"></div><div class="cornerBottomRight"></div><div class="cornerBottomLeft"></div>');



	//Copy Fields from one Form to another
	function getUrlParam(str)
	{
		if(typeof str != 'string')return null;//If not string return null
		var sLoc = window.location.toString().split('?');//Get url and split it according to '?'
		if(sLoc.length == 1)return null;//If there are no parameters in url return null
		
		var params = sLoc[1].split('&');//Get url params array
		for(var i = 0; i < params.length; i++)//Loop through url params
		{
						if(params[i].match(new RegExp(str + '=','gi')) != null)return decodeURIComponent(params[i].split('=')[1]);//If found return it
		}
		return null;//Return null
	}
	
	//Paste copied fields into same [new field] ID's
	$('form[name=catwebformform8169] input[type=text]').each(function(){
		var param = getUrlParam($(this).attr('name'));
		if(param)$(this).val(param.replace(/\+/gi, " "));
		
	});


	//Find if home page and apply script
	if ( $('body#home').length == 1 ) {
		$('#banner')
		//.after('<div id="nav">')
		.cycle({
			fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
			//next: 'a.link-next', 
			//prev: 'a.link-prev',
			timeout: 4000,  // milliseconds between slide transitions (0 to disable auto advance)
			//pager: '#nav',
			cleartypeNoBg: true
		});
	}
	else if ( $('body#solutions').length == 1 ) {
		$('#banner')
		.cycle({
			fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
			timeout: 4000,
			cleartypeNoBg: true
		});
	}
	

});
