//--------------------------------------------------
// sIFR

	var ocrf = { src: '/a/swf/global/ocrf.swf'};
	sIFR.activate(ocrf);

	// Aside

		sIFR.replace(ocrf,{
			selector: '#aside .projectPink h2, #aside #gridGirlNavigation h2',
			wmode: 'transparent',
			css:[
				'.sIFR-root { color: #ff0099; }',
				'.sIFR-root a { color: #ff0099; text-decoration: none; }',
				'.sIFR-root a:hover { color: #ffffff; text-decoration: none; }',
				'.sIFR-root a:visited { color: #ffffff; text-decoration: none; }'
			]
		});

		sIFR.replace(ocrf,{
			selector: '#aside h2',
			wmode: 'transparent',
			css:[
				'.sIFR-root { color: #00aeef; }',
				'.sIFR-root a { color: #00aeef; text-decoration: none; }',
				'.sIFR-root a:hover { color: #ffffff; text-decoration: none; }',
				'.sIFR-root a:visited { color: #ffffff; text-decoration: none; }'
			]
		});

		sIFR.replace(ocrf,{
			selector: '#discount h2, #poll h3',
			wmode: 'transparent',
			css:'.sIFR-root{color:#ffffff;}'
		});

	// Tyres

		sIFR.replace(ocrf,{
			selector: '#brands h2',
			wmode: 'transparent',
			css:'.sIFR-root{color:#00A8EB;}'
		});

		sIFR.replace(ocrf,{
			selector: '.goodyear #description h2',
			wmode: 'transparent',
			css:'.sIFR-root{color:#00259b;}'
		});

		sIFR.replace(ocrf,{
			selector: '#reliable h2 #inAustria h2',
			wmode: 'transparent',
			css:'.sIFR-root{color:#00aeef;}'
		});

		sIFR.replace(ocrf,{
			selector: '#freeze h3',
			wmode: 'transparent',
			css:'.sIFR-root{color:#000000;}'
		});

	// MOTs & Services

		sIFR.replace(ocrf,{
			selector: '#book h2',
			wmode: 'transparent',
			css:'.sIFR-root{color:#ffffff;}'
		});

		sIFR.replace(ocrf,{
			selector: '#view h2',
			wmode: 'transparent',
			css:'.sIFR-root{color:#000000;}'
		});

	// HiQ Centres

		sIFR.replace(ocrf,{
			selector: '#findAFitter h2, #bookTyreFitting h2, #services h2, #ambiguous h2',
			wmode: 'transparent',
			css:'.sIFR-root{text-align:left; color:#00A8EB;}'
		});

		sIFR.replace(ocrf,{
			selector: '#franchiseFindAFitter h2',
			wmode: 'transparent',
			css:'.sIFR-root{text-align:left; color:#000000;}'
		});

	// News

		sIFR.replace(ocrf,{
			selector: '#subCategories h3, #archive h3',
			wmode: 'transparent',
			css:'.sIFR-root{color:#00A8EB;}'
		});

	// Project Pink

		sIFR.replace(ocrf,{
			selector: '#donation h2',
			wmode: 'transparent',
			css:[
				'.sIFR-root { color: #000000; }',
				'.sIFR-root strong { color: #ff0099; text-decoration: none; }',
			]
		});
		
		// Pink OCtober
		sIFR.replace(ocrf,{
			selector: '#raisingFunds h2, .pinkOctober h2',
			wmode: 'transparent',
			css:[
				'.sIFR-root { color: #ff0099; }',
			]
		});

		sIFR.replace(ocrf,{
			selector: '#counts h2, h2#pinkGallery, #content #newsFeed h2#pinkNews',
			wmode: 'transparent',
			css:'.sIFR-root{color:#ff0099;}'
		});

	// HiQ+You

		sIFR.replace(ocrf,{
			selector: '#leading h2',
			wmode: 'transparent',
			css:'.sIFR-root{text-align:left; color:#000000;}',
			css:'.sIFR-root strong{color:#ffffff; font-weight: normal}'
		});

	// HiQ BTCC

		sIFR.replace(ocrf,{
			selector: '#nominate #thankYou h2, #btccNews h2',
			wmode: 'transparent',
			css:'.sIFR-root{color:#00A8EB;}'
		});

		sIFR.replace(ocrf,{
			selector: '#previous h2, #drivers h2, #nominate h2',
			wmode: 'transparent',
			css:'.sIFR-root{color:#ffffff;}'
		});

		sIFR.replace(ocrf,{
			selector: 'h1.gridGirl',
			wmode: 'transparent',
			css:'.sIFR-root{color:#ff0099;}'
		});

	// Part worn

		sIFR.replace(ocrf,{
			selector: '#partWorn h1',
			wmode: 'transparent',
			css:'.sIFR-root{color:#00aeef;}'
		});


	// Offers & Promotions - Goodyear Blimp

		sIFR.replace(ocrf,{
			selector: '#competition h2',
			wmode: 'transparent',
			css:'.sIFR-root{color:#ffffff;}'
		});

		sIFR.replace(ocrf,{
			selector: '#competition h3',
			wmode: 'transparent',
			css:'.sIFR-root{color:#000000;}'
		});

		sIFR.replace(ocrf,{
			selector: '#gridGirl h3',
			wmode: 'transparent',
			css:[
				'.sIFR-root { color: #ff0099; }',
				'.sIFR-root a { color: #ff0099; text-decoration: none; }',
				'.sIFR-root a:hover { color: #ff0099; text-decoration: underline; }',
				'.sIFR-root a:visited { color: #ff0099; text-decoration: none; }'
			]
		});

	// Homepage

		sIFR.replace(ocrf,{
			selector: '#introduction h1',
			wmode: 'transparent',
			css:'.sIFR-root{color:#ffffff;}'
		});

		sIFR.replace(ocrf,{
			selector: '#quick h2',
			wmode: 'transparent',
			css:'.sIFR-root{color:#00aeef;}'
		});

		sIFR.replace(ocrf,{
			selector: '#choose h2, #hiqCentres h2',
			wmode: 'transparent',
			css:'.sIFR-root{color:#00aeef;}'
		});
		
	// Car Care - Warranty

		sIFR.replace(ocrf,{
			selector: '#mbi h1, #smartAccidentRepair h1',
			wmode: 'transparent',
			css:'.sIFR-root{color:#ffffff;}'
		});

		sIFR.replace(ocrf,{
			selector: '#backToSchool h1',
			wmode: 'transparent',
			css:'.sIFR-root{color:#000000;}',
			css:'.sIFR-root strong {color:#00aeef;}'
		});

	// Global

		sIFR.replace(ocrf,{
			selector: 'h1,h2',
			wmode: 'transparent',
			css:'.sIFR-root{text-align:left; color:#000000;}',
			css:'.sIFR-root a{color: #00aeef; text-decoration: none; text-transform: uppercase;}',
			css:'.sIFR-root a:hover{color: #00aeef; text-decoration: underline}'
		});

//Sliding Drawers

$(function () {
	/**
	* hide elements with class hideMe
	*/
	$(".hideMe").hide(), $(".showMe").show(),

	/**
	* register the sliding behaviour with the tools toolBox
	*/
	$("#searchBySliders").find("li").find("span.slidyToolsBigTitle").wrap('<a href="#" class="clickHere"></a>').removeClass('searchBySlidersBigTitle'),
	$("#searchBySliders").find("li").find("a.clickHere").each (function () {
		var whatsTheHref=$(this).attr('href');
	
			$(this).click( function () {
				
				obj=$(this);
				
				$("#searchBySliders").find("span.current").each ( function () {
					//get rid of the "current" class
					$(this).removeClass("current");
				});
				
				$("#searchBySliders").find("div.hideMe").each ( function () {
					// hide all open sections
					if ($(this).is(":visible"))
					{
						$(this).slideUp("500");
					}
				});

				// open this section if it's hidden
				if ($(this).next().is(":hidden"))
				{
					$(this).next().slideDown("500");

					obj.find("span").each ( function () {
						$(this).addClass("current")
					});
				}
				
				return false;
			});
	})

});

/*--------------------------------------------------*/
/* Common Components 			                    */

	$(document).ready(function(){

		//--------------------------------------------------
		// Aside Navigation

			if ($(".navigation").length > 0){

				$(".navigation").treeview({
					animated: 'fast',
					persist: "location",
					collapsed: true,
					unique: true
				});

			};

		//--------------------------------------------------
		// News Feed

			if ($("#newsFeed").length > 0){

				$('#newsFeed li:nth-child(even)').addClass('even');
				$('#newsFeed li:last-child').addClass('last');

			    jQuery('#newsFeed ul').jcarousel({
			        vertical: true,
			        scroll: 2,
					wrap: true,
					buttonNextHTML: "<div class='jcarousel-next'>Older</div>",
					buttonPrevHTML: "<div class='jcarousel-prev'>Newer</div>"
			    });

			};

		//--------------------------------------------------
		// Facebook activity

			if ($("#facebookActivity").length > 0){
				$('#facebookActivity').html('<iframe src="//www.facebook.com/plugins/activity.php?site=hiqonline.co.uk&amp;width=380&amp;height=200&amp;header=false&amp;colorscheme=light&amp;linktarget=_blank&amp;border_color=%23ffffff&amp;font=arial&amp;recommendations=false" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:380px; height:200px;" allowTransparency="true"></iframe>')
			};

		//--------------------------------------------------
		// Track outbound links

			$('a.popup').click(function(){
				_gaq.push(['_trackEvent','Outbound link','',$(this).attr('href')]);
			});

		//--------------------------------------------------
		// IE Fixes

			$('input').hover(function(){
				$(this).toggleClass('hover');
			});

			$('input').focus(function(){
				$(this).toggleClass('focus');
			});

	});

