$(document).ready(function(){

//---------- STARTUP -----------------------------------------------------------------------------------------------

	var crtPage = $('#outerContain').attr('class');
	var opacityLow = 0.6;
	$('.hoverLink, .topLevel, .leftOver, .slideNav').css({opacity:opacityLow});
	hoverBackColor('.topModalBtn', '#2fb0ea', '', 'no');
	
//---------- UNIVERSAL TOP -----------------------------------------------------------------------------------------
	$('#contactUs').click(function(){
		getModal('includes/inc_contact.php', 'contact');
	});
	
	//Login Links Hover
	$('#loginListContain').hover(function(){
		$('#loginList').show();
	}, function(){
		$('#loginList').hide();
	});
	
//---------- NAVIGATION --------------------------------------------------------------------------------------------

	//For when you hover over a link without a sub menu
	$('.hoverLink').hover(function(){
		$('.subMenu:visible').slideUp('fast',function(){
				$(this).parent().find('.topLevel').animate({opacity:opacityLow}, 220);
		});
		$(this).animate({opacity:0.99}, 260);
		
	}, function(){
		$(this).animate({opacity:opacityLow}, 220);
		
	});
	
	//For when you hover over a link with a sub menu
	$('.topLevel').mouseover(function(){
		if($(this).parent().find('.subMenu:visible').html() == null){
			$('.subMenu:visible').slideUp('fast',function(){
					$(this).parent().find('.topLevel').animate({opacity:opacityLow}, 220);
			});
			$(this).parent().find('.subMenu').slideDown('fast', 'easeOutQuad');
		}
		$(this).animate({opacity:0.99}, 260);
		
	});
	
	//Collapse navigation sub menu
	$('.collapseNav').mouseover(function(){
		$('.subMenu:visible').slideUp('fast', function(){
				$(this).parent().find('.topLevel').animate({opacity:opacityLow}, 220);
		});
	});

//---------- MULTIPLE PAGES ---------------------------------------------------------------------------------------	
	if((crtPage == 'solutionsPage') || (crtPage == 'productsPage') || (crtPage == 'outsourcingPage') || (crtPage == 'magicPage') || (crtPage == 'partnerPage')){	
		
		//Effects Functions
		makeLink('.contactRequestBtn, .guidesDownloadsBtn, .dwnlRep');
		
		//Contact Rep Modal
		$('.contactRequestBtn').click(function(){
			getModal('includes/inc_contact_me.php', 'contactMe');
		});
		
		//Download Guides Modal
		$('.guidesDownloadsBtn, .dwnlRep').click(function(){
			getModal('includes/inc_download_rep.php', 'downloadGuides');
		});
		
	}
	
//---------- MAGIC PAGE SPECIFIC ----------------------------------------------------------------------------------

	if(crtPage == 'magicPage'){	
	
		//Side Navigation Effects
		$('.sideNavLink:odd').css({backgroundColor:'#f8f7fb'});
		$('.sideNavLink:even').css({backgroundColor:'#FFFFFF'});
		$('#submitNewsInput2').click(function(){
			if($('#newsInput2').val() != ''){
				newsletterJoin($('#newsInput2').val());
			}
		});
		makeLink('.sideNavLink, h2, #submitNewsInput2');
		hoverBackColor('.sideNavLink', '#d0e8ff', '', 'yes');
		hoverLine('h2');
		
		//AJAX Content Pull In
		$('.sideNavLink').click(function(){
			//Loading gif
			$('#infoSecMain').html('<div class="loader">&nbsp;&nbsp;Loading Data...</div>');
			
			$.post('includes/'+$(this).attr('name')+'.php', 
			{
				ajax: 'ajaxCall'
			}
			, function($data)
			{
				$('#infoSecMain').html($data);
				
				//Call in career selection function
				careerSelect();
				
				makeLink('#submitNewsInput2, h2');
				hoverLine('h2');
		
				$('#submitNewsInput2').click(function(){
					if($('#newsInput2').val() != ''){
						newsletterJoin($('#newsInput2').val());
					}
				});
			});
			/*$('#infoSecMain').load('includes/'+$(this).attr('name')+'.php', function(){
		
				//Call in career selection function
				careerSelect();
				
				makeLink('#submitNewsInput2, h2');
				$('#submitNewsInput2').click(function(){
					if($('#newsInput2').val() != ''){
						newsletterJoin($('#newsInput2').val());
					}
				});
			});*/
		});
		
		//Call in career selection function
		careerSelect();
		
		//AJAX Content Pull In
		$('.emergeMenu .sideNavLink').click(function(){
													 
			//Loading gif
			$('#infoSecMain').html('<div class="loader">&nbsp;&nbsp;Loading Data...</div>');
			$('#infoSecMain').load('includes/inc_emerge_person.php', { emPerson: $(this).attr('id').substr(2) }, function(){
				
				//Effects Functions
				makeLink('#filteredBlogs h2');
				hoverLine('#filteredBlogs h2');
				
			});
		});
	}
	
//---------- PARTNER PAGE SPECIFIC ----------------------------------------------------------------------------------

	if(crtPage == 'partnerPage'){
		//Navigation function call
		newsNav('custom','partnerPage');
	}
	
//---------- HOME PAGE SPECIFIC ----------------------------------------------------------------------------------

	if(crtPage == 'homePage'){
		//Navigation function call
		newsNav('custom','newsPage');
		//Banner function call
		paneControl();
		makeLink('#btnJoinNewsletter');
	
		// Join Newsletter Focus Code
		$('#joinNewsletter1').focus(function(){
			if($(this).val() == $(this).attr('title')){
				$(this).val('');
			}
		});
		
		$('#joinNewsletter1').blur(function(){
			if($(this).val() == ''){
				$(this).val($(this).attr('title'));
			}
		});
		
		$('#btnJoinNewsletter').click(function(){
											   
			if($('#joinNewsletter1').val() != ''){
				newsletterJoin($('#joinNewsletter1').val());
				$('#joinNewsletter1').val($('#joinNewsletter1').attr('title'));
			}
		});

	}
	
//---------- SOLUTIONS PAGE SPECIFIC ------------------------------------------------------------------------------

	if(crtPage == 'solutionsPage'){		
		//Side Navigation
		$('.sideNavLink:odd').css({backgroundColor:'#f8f7fb'});
		$('.sideNavLink:even').css({backgroundColor:'#FFFFFF'});
		makeLink('.sideNavLink, .miniBanLink, .openLink');
		hoverUnderline('.openLink');
		hoverBackColor('.sideNavLink', '#d0e8ff', '', 'yes');
		//AJAX Content Pull In
		$('.sideNavLink, .miniBanLink, .openLink').click(function(){
			//Loading gif
			$('#infoSecMain').html('<div class="loader">&nbsp;&nbsp;Loading Data...</div>');
			$('#infoSecMain').load('includes/'+$(this).attr('name')+'.php',{startpage: $(this).attr('title')} , function(){
																														 
				clientSlider();
				makeLink('.openLink');
				hoverUnderline('.openLink');
				
				$('.openLink').click(function(){
					//Loading gif
					$('#infoSecMain').html('<div class="loader">&nbsp;&nbsp;Loading Data...</div>');
					$('#infoSecMain').load('includes/'+$(this).attr('name')+'.php',{startpage: $(this).attr('title')}, function(){
																																
						//Download Guides Modal
						$('.dwnlRep').click(function(){
							getModal('includes/inc_download_rep.php', 'downloadGuides');
						});
						//Call in the Client Slider function for the first time
						clientSlider();
						
					});
				});
				
				//Download Guides Modal
				$('.dwnlRep').click(function(){
					getModal('includes/inc_download_rep.php', 'downloadGuides');
				});
				
			});
		});
		//Call in the Client Slider function for the first time
		clientSlider();
	}
	
//---------- PRODUCTS PAGE SPECIFIC ----------------------------------------------------------------------------

	if(crtPage == 'productsPage'){		
		//Side Navigation
		$('.sideNavLink:odd').css({backgroundColor:'#f8f7fb'});
		$('.sideNavLink:even').css({backgroundColor:'#FFFFFF'});
		makeLink('.sideNavLink');
		hoverBackColor('.sideNavLink', '#d0e8ff', '', 'yes');
		//AJAX Content Pull In
		$('.sideNavLink').click(function(){
			//Loading gif
			$('#infoSecMain').html('<div class="loader">&nbsp;&nbsp;Loading Data...</div>');
			$('#infoSecMain').load('includes/'+$(this).attr('name')+'.php',{startpage: $(this).text()} , function(){
				clientSlider();
			});
		});
		//Call in the Client Slider function for the first time
		clientSlider();
	}
	
//---------- OUTSOURCING PAGE SPECIFIC ------------------------------------------------------------------------

	if(crtPage == 'outsourcingPage'){		
		//Side Navigation
		$('.sideNavLink:odd').css({backgroundColor:'#f8f7fb'});
		$('.sideNavLink:even').css({backgroundColor:'#FFFFFF'});
		makeLink('.sideNavLink');
		hoverBackColor('.sideNavLink', '#d0e8ff', '', 'yes');
		makeLink('.makeLink');
		//Other Input Box Shows
		$('select[name="hearAboutUs"]').change(function(){
														
			if($(this).val() == 'Other'){
				$('#inpOther1').slideDown(function(){ $('input[name="hearAboutUsOther"]').focus(); });
				
			}else{
				$('#inpOther1').slideUp();				
			}
			
		});
		
		$('select[name="mainReason"]').change(function(){
														
			if($(this).val() == 'Other'){
				$('#inpOther2').slideDown(function(){ $('input[name="mainReasonOther"]').focus(); });
				
			}else{
				$('#inpOther2').slideUp();				
			}
			
		});
		
		//Online Quote Submission
		$('#submitQuote').click(function(){
			//Make checks to see neccessary fields are complete
			if(($('input[name="title"]').val() == '') || ($('input[name="firstName"]').val() == '') || ($('input[name="lastName"]').val() == '') || ($('input[name="companyName"]').val() == '') || ($('input[name="contactNumber"]').val() == '') || ($('select[name="hearAboutUs"]').val() == '') || ($('input[name="numberOfboxes"]').val() == '')){
				
				alert('Please fill in all required fields');
				
			}else{
				//If they want to recieve updates then they need to fill in their email address
				if(($('input[name="yesRecieve"]:checked').length == 1) && $('input[name="emailAddress"]').val() == ''){
					alert('Please fill in your email address in order to receive future updates via email');
				}else{
			
					if($('input[name="yesRecieve"]:checked').length == 1){
						// Ajax Call
						$.post("simple/process.php", {
							address: $('input[name="emailAddress"]').val()
							
						}, function(){
							$('#onlineQuoteForm').submit();
							
						});
						
					}else{
						$('#onlineQuoteForm').submit();
					}
					
				}
				
			}
		});
		//AJAX Content Pull In
		$('.sideNavLink').click(function(){
			//Loading gif
			$('#infoSecMain').html('<div class="loader">&nbsp;&nbsp;Loading Data...</div>');
			$('#infoSecMain').load('includes/'+$(this).attr('name')+'.php',{startpage: $(this).text()} , function(){
				makeLink('.makeLink');
				//Other Input Box Shows
				$('select[name="hearAboutUs"]').change(function(){
																
					if($(this).val() == 'Other'){
						$('#inpOther1').slideDown(function(){ $('input[name="hearAboutUsOther"]').focus(); });
						
					}else{
						$('#inpOther1').slideUp();				
					}
					
				});
				
				$('select[name="mainReason"]').change(function(){
																
					if($(this).val() == 'Other'){
						$('#inpOther2').slideDown(function(){ $('input[name="mainReasonOther"]').focus(); });
						
					}else{
						$('#inpOther2').slideUp();				
					}
					
				});
				
				//Online Quote Submission
				$('#submitQuote').click(function(){
					//Make checks to see neccessary fields are complete
					if(($('input[name="title"]').val() == '') || ($('input[name="firstName"]').val() == '') || ($('input[name="lastName"]').val() == '') || ($('input[name="companyName"]').val() == '') || ($('input[name="contactNumber"]').val() == '') || ($('select[name="hearAboutUs"]').val() == '') || ($('input[name="numberOfboxes"]').val() == '')){
						
						alert('Please fill in all required fields');
						
					}else{
						//If they want to recieve updates then they need to fill in their email address
						if(($('input[name="yesRecieve"]:checked').length == 1) && $('input[name="emailAddress"]').val() == ''){
							alert('Please fill in your email address in order to receive future updates via email');
						}else{
					
							if($('input[name="yesRecieve"]:checked').length == 1){
								// Ajax Call
								$.post("simple/process.php", {
									address: $('input[name="emailAddress"]').val()
									
								}, function(){
									$('#onlineQuoteForm').submit();
									
								});
								
							}else{
								$('#onlineQuoteForm').submit();
							}
							
						}
						
					}
				});
			});
		});
	}
	
//---------- BLOG PAGE SPECIFIC ------------------------------------------------------------------------

	if(crtPage == 'blogPage'){	
		
		//Side Navigation
		$('.sideNavLink:odd').css({backgroundColor:'#f8f7fb'});
		$('.sideNavLink:even').css({backgroundColor:'#FFFFFF'});
		
		//Effects Functions
		makeLink('.sideNavLink, .latestBlogHead, .catCloudItem');
		hoverBackColor('.sideNavLink', '#d0e8ff', '', 'yes');
		hoverColour('.latestBlogHead, .catCloudItem');
		
		//Initial AJAX Setup
		ajaxLinks();
		
		//AJAX Call
		$('.sideNavLink, .latestBlogHead, .catCloudItem').click(function(){
			//Call the page results															 
			blogAjaxCall($(this).attr('id').substr(2), $(this).attr('name'), "sideNav");
		});
		
		//All Blogs AJAX Call
		$('#allBlog').click(function(){
			//Call the page with "showAll" value
			blogAjaxCall("showAll", "none", "allBlogs");
		});
		
	//End Of Blog Page Specific	
	}
	
	
	
	
//---------- FUNCTIONS ----------------------------------------------------------------------------------------

	//---------- Career Selection Function
	function careerSelect(){
		$('.careerSelect').click(function()
		{
			//Variable
			$thisId = $(this).attr('name');;
			
			//Loading gif
			$('#infoSecMain').html('<div class="loader">&nbsp;&nbsp;Loading Data...</div>');
			$.post('includes/inc_careers.php',
			{
				careerId: $thisId	
			}
			, function($data)
			{
				$('#infoSecMain').html($data);
				makeLink('.goBackBtn');
				$('#careerBack').click(function(){
					$('.trigCareerBack').click();
				});
			});
		});
	}
	
	//---------- Quote Function -------
	function quoteForm(){	
	}
	
	//---------- Email Newsletter Function -------
	function newsletterJoin($emailAddress){
		//alert($emailAddress);
		// Ajax Call
		$.post('simple/process.php', {
			address: $emailAddress
				
		}, function(data){
			$('#newsInput2').val('');
		});
	}
	
	//---------- Blog Article Function -------
	
	function blogAjaxCall(varBlogRef, varBlogCat, varBlogCon){
		//Loading gif
		$('#infoSecMain').html('<div class="loader">&nbsp;&nbsp;Loading Data...</div>');
		$('#infoSecMain').load('includes/inc_blog.php',{blogRef: varBlogRef, blogCat: varBlogCat, blogCon: varBlogCon}, function(){
			ajaxLinks();
		});	
	}
	
	
	//---------- Blog Inner AJAX Links ----
	
	function ajaxLinks(){
		
		//Effects
		makeLink('#filteredBlogs h2, .blogLink, .goBackBtn');
		hoverLine('#filteredBlogs h2');
		hoverColour('.blogLink');
			
		//Blogger Connector Click
		$('.blogBotNLink').click(function(){
			blogConnect($(this).attr('title'), 'li', 'title');
		});
			
		//Tag Connector Click
		$('.blogBotCLink').click(function(){
			blogConnect($(this).attr('title'), 'li', 'title');
		});
		
		//All Blogs AJAX Call
		$('#filterLink').click(function(){
			//Call the page using a connector
			blogConnect($(this).attr('name'), 'li', 'id');
		});
		
		//AJAX Call
		$('#filteredBlogs h2').click(function(){
			//Call the page results			 
			blogAjaxCall("filterLink", $(this).attr('name'), $('#filteredBlogs').attr('name'));
		});
	}
	
	
	//---------- Blogger Connect Function -----
	
	function blogConnect(connectTo, connectType, connectWhat){
		if(connectTo != 'rfallBlog'){
			$(''+connectType+'['+connectWhat+'="'+connectTo+'"]').trigger('click');
		}else{
			$('#'+connectTo.substr(2)).trigger('click');
		}
	}
	

	//---------- Modal Function Call ----------
	
	function getModal(address, whichModal){
		$.get(address, function(data){
			$(data).modal({
				overlay: 50,
				onShow: function(){
					//Which Modal settings to use
					if(whichModal == 'contact'){
						contactModal(); //Contact Modal Option
					}else if(whichModal == 'contactMe'){
						contactMeModal(); //Contact Me Modal Option
					}else if(whichModal == 'downloadGuides'){
						downloadGuides();
					}
					//Call png fix if browser is IE
					if($.browser.msie){
						pngFix();			
					}
					//Call in menu change function
				}
			});
		});
	
	}
	
	
	//---------- Contact Modal Settings Function ----------
	
	function contactModal(){
		//Lighten Close button
		$('.modalClose').addClass('pngFix').css({opacity:0.9});
		//Call Effects Functions
		makeLink('.modalClose, .modalContactLink');
		hoverBackColor('.modalContactLink', '#62b5f2', '#55a9ee');
		//Show First Entry
		$('.modalContactDetail:first').show();
		$('.modalContactLink').click(function(){
			$('.modalContactDetail').hide();
			var modalContacId = $(this).attr('name').substring(7);  //Get Name Number
			$('.modalContactDetail:eq('+modalContacId+')').fadeIn(function(){
				if($.browser.msie){
					this.style.removeAttribute('filter'); 
				}
			});
		});
	}
	
	
	//---------- ContactMe Modal Settings Function ----------
	
	function contactMeModal(){
		//Lighten Close button
		$('.modalClose').addClass('pngFix').css({opacity:0.9});
		//Call Effects Functions
		makeLink('.modalClose, .modalSend');
		//Send Button Function
		$('.modalSend').click(function(){
			if($('#contactMeMessage').val() == ""){
				ctcMeMessageRaw = "This person has no message";
			}else{
				ctcMeMessageRaw = $('#contactMeMessage').val();
			}
					
			if(($('#contactMeName').val() == "") || ($('#contactMeCompany').val() == "") || ($('#contactMeNumber').val() == "") || ($('#contactMeEmail').val() == "")){
				alert('Please note that all fileds are required to be filled in except "Message"');
			}else{
				//Send variables to through page
				$.get('throughpages/tp_contact_me.php',{
					ctcMeName : $('#contactMeName').val(),
					ctcMeCompName : $('#contactMeCompany').val(),
					ctcMeNo : $('#contactMeNumber').val(),
					ctcMeEmail : $('#contactMeEmail').val(),
					ctcMeMessage : ctcMeMessageRaw
				});
				//alert($('#contactMeMessage').val());
				$.modal.close();  //Close the modal
			}
		});
	}
	
	
	//---------- Download Modal Settings Function ----------
	
	function downloadGuides(){
		//Lighten Close button
		$('.modalClose').addClass('pngFix').css({opacity:0.9});
		//Call Effects Functions
		makeLink('.modalClose, .modalGLink, .modalRLink, #modalNavUp, #modalNavDown');
		//Resources Highlight
		$('.modalRLink').hover(function(){
			var downloadLink = $(this).attr('name').substring(8);
			$('.modalResDwnld:eq('+downloadLink+')').css({backgroundColor:'#55a9ee'});
		}, function(){
			var downloadLink = $(this).attr('name').substring(8);
			$('.modalResDwnld:eq('+downloadLink+')').css({backgroundColor:''});
		});
		//Guide Highlight
		$('.modalGLink').hover(function(){
			var downloadLink = $(this).attr('name').substring(8);
			$('.modalGuideDwnld:eq('+downloadLink+')').css({backgroundColor:'#55a9ee'});
		}, function(){
			var downloadLink = $(this).attr('name').substring(8);
			$('.modalGuideDwnld:eq('+downloadLink+')').css({backgroundColor:''});
		});
		//Modal Slider
		var modalSlideMargTop = 0
		var modalDiff
		var modalSlideMax = $('#modalSliderHeight').height();
		//Slide Up
		$('#modalNavUp').click(function(){
			if(modalSlideMargTop > 0){
				modalSlideMargTop = modalSlideMargTop - 200;
				$('.modalSlider').animate({marginTop:-modalSlideMargTop}, 1400, "easeOutQuad");
			}
		});
		//Slide Down
		$('#modalNavDown').click(function(){
			modalDiff = modalSlideMax - modalSlideMargTop;
			if((modalSlideMax > 270) && (modalDiff > 270)){
				modalSlideMargTop = modalSlideMargTop + 200;
				$('.modalSlider').animate({marginTop:-modalSlideMargTop}, 1400, "easeOutQuad");
			}
		});
	}

	
	//---------- Client Information Slider Function ----------
	
	function clientSlider(){
		//Effects Functions
		hoverBack('.clientInfoBtn');
		makeLink('.clientInfoBtn');
		//Information Button Click
		$('.clientInfoBtn').click(function(){
			var thisMarginTop = $(this).parent().css("marginTop");  //Top Margin
			if(thisMarginTop == '166px'){
				//Animate Open
				$(this).parent().animate({marginTop: 0}, function(){
					$(this).find('.clientInfoMain').fadeIn();
				});
			}else{
				//Animate Closed
				$(this).parent().find('.clientInfoMain').fadeOut(function(){
					$(this).parent().animate({marginTop: 166});
				});
			}
		});
	}
	

	//---------- Slide Pane Control Function ----------
	
	function paneControl(){
		
		//Some initial variables
		var slidePos = 0;
		var slideCount = 0;
		var slideWidth = $('.slidePane').width();
		var shiftVal; //just declaring the variable
		var autoInter = 10000;
		var noClick = "no";
		
		//Determine the amount of slides that there are and insert the menu
		$('.slidePane').each(function(){
			slideCount++;
			$('#slideNoContain').append('<div class="slideNo">'+slideCount+'</div>');
		});
		
		//Animate Slider - Once Off Play Through
		$('.test').animate({marginLeft:1}, 45000, function(){
			slidePos++;
			if((slidePos < slideCount) && (noClick == "no")){
				paneSlide(slidePos, slideWidth, 800);
				$('.test').animate({marginLeft:2}, autoInter, function(){
					slidePos++;
					if((slidePos < slideCount) && (noClick == "no")){
						paneSlide(slidePos, slideWidth, 800);
						$('.test').animate({marginLeft:3}, autoInter, function(){
							slidePos++;
							if((slidePos < slideCount) && (noClick == "no")){
								paneSlide(slidePos, slideWidth, 800);
								$('.test').animate({marginLeft:4}, autoInter, function(){
									slidePos++;
									if((slidePos < slideCount) && (noClick == "no")){
										paneSlide(slidePos, slideWidth, 800);
										$('.test').animate({marginLeft:5}, autoInter, function(){
											slidePos++;
											if((slidePos < slideCount) && (noClick == "no")){
												paneSlide(slidePos, slideWidth, 800);
												$('.test').animate({marginLeft:6}, autoInter, function(){
												});
											}
										});
									}
								});
							}
						});
					}
				});
			}
		});
		
		$('.slideNo').css({opacity:0.2});
		
		//Slide Pane - with slide number click
		$('.slideNo').click(function(){
			noClick = "yes";
			shiftVal = -(($(this).text() * slideWidth) - slideWidth);
			slidePos = $(this).text() - 1;
			//Slide Pane
			paneSlide(slidePos, slideWidth, 1200);
		});
		
		$('.slideNo').hover(function(){
			if($(this).text() != (slidePos + 1)){
				$(this).css({opacity:0.6});
			}
		}, function(){
			if($(this).text() != (slidePos + 1)){
				$(this).css({opacity:0.2});
			}
		});
		
		$('.slideNo:first').css({opacity:0.6});
		
		//Slide Pane - with Buttons
		$('.slideNav').click(function(){
			//Get id	  
			var slideNav = $(this).attr('id');
			//Condition based on the id - ie. next or previous sliding
			if((slideNav == 'slideNavPrev') && (slidePos > 0)){
				slidePos--;
				paneSlide(slidePos, slideWidth, 800);
				
			}else if((slideNav == 'slideNavNext') && (slidePos < (slideCount - 1))){
				slidePos++;
				paneSlide(slidePos, slideWidth, 800);
			}

		//End Of Slide Pane
		});
	}
	
	
	//---------- Pane Sliding Animation Function ----------
	
	function paneSlide(slidePos, slideWidth, slideSpeed){
		$('.slideNo').css({opacity:0.2});
		$('.slideNo:eq('+slidePos+')').css({opacity:0.6});
		shiftVal = -(slidePos * slideWidth);
		//Slide Pane
		$('#slider').animate({marginLeft:shiftVal}, slideSpeed, "easeInOutQuad");
	}
	
	
	//---------- News Nav Function ----------
	
	function newsNav(scrollbar, thisPage){
		$('.newsSub:first').show().addClass('subActive');
		$('.newsItem:odd').css({backgroundColor:'#f8f7fb'});
		
		//Active scroll bar customization
		if(scrollbar == 'custom'){
			$('.newsArticle').jScrollPane({
				showArrows: 'true',
				scrollbarWidth: 14
			});
		}
		
		//Change news article to selection - AJAX call
		$('.newsItem').click(function(){
			if(thisPage == 'newsPage'){
				var newsId = $(this).attr('name');
				//Function call
				newsArticle(newsId);
			}else if(thisPage == 'partnerPage'){
				//Loading gif
				$('#infoSecMain').html('<div class="loader">&nbsp;&nbsp;Loading Data...</div>');
				$('#infoSecMain').load('includes/inc_partners_info.php',{emPartner: $(this).text()} , function(){});
			}
		});
		
		//News category sliding animation
		$('.newsCat').click(function(){
			var thisSub = $(this).next('div');
			var test = thisSub.attr('class');
			if(thisSub.hasClass('subActive')){
			}else{
				$('.subActive').removeClass('subActive');
				thisSub.addClass('subActive');
				$('.newsSub:visible').slideUp('fast', function(){
					thisSub.slideDown('fast');
				});
			}
		});
		
		$('.newsItem:odd').css({backgroundColor:'#f8f7fb'});
		$('.newsItem:even').css({backgroundColor:'#FFFFFF'});
		hoverBackColor('.newsItem', '#d8e2f6', '', 'yes');
		makeLink('.newsItem');
		
	//End Of Nav Function	
	}
	
	
	//---------- News Article Function ---------
	
	function newsArticle(id){
		if(id != null){
			//Loading gif
			$('.newsArticle').html('<div class="loader"></div>');
			
			//ARCHIVE SECTION
			if((id == 'archive2007') || (id == 'archive2006')){
				//AJAX call
				$('.newsArticle').load('includes/inc_news_archive.php',{
					newsId: id
				}, function(){
					$('.newsArticle').jScrollPane({
					showArrows: 'true',
					scrollbarWidth: 14
					});
					makeLink('.newsArchHead');
					
					$('.newsArchHead').hover(function(){
						$(this).css({textDecoration: 'underline'});
					}, function(){
						$(this).css({textDecoration: 'none'});
					});
					
					$('.newsArchHead').click(function(){
						//Loading gif
						$('.newsArticle').html('<div class="loader"></div>');
						$thisNewsId = $(this).attr('name');
						//AJAX call
						$('.newsArticle').load('includes/inc_news_article.php',{
							newsId: $thisNewsId
						}, function(){
							$('.newsArticle').jScrollPane({
							showArrows: 'true',
							scrollbarWidth: 14
							});
						});
					});
				});
				
			}else{
				//AJAX call
				$('.newsArticle').load('includes/inc_news_article.php',{
					newsId: id
				}, function(){
					$('.newsArticle').jScrollPane({
					showArrows: 'true',
					scrollbarWidth: 14
					});
				});
			}
			
		}
	}
	
	
	//---------- IE Png Fix Function ---------
	
	if($.browser.msie){
		//Test That The Link Works
		//alert("If you see this message and the fix has not worked then change the imgPathDirty substring value.  Else if it does then YAY it works");
											
		//----------------------------- IMAGE REPLACEMENT FUNCTION--------------
		function pngFix(){
			$('.pngFix').each(function (i) {
				var cssBack = $(this).css("backgroundImage");
				if(cssBack.match(".png")){
					imgPathDirty = cssBack.substring(5);
					//alert(imgPathDirty);
					imgPath1 = imgPathDirty.replace(')','');
					imgPath2 = imgPath1.replace('"','');
					//alert(imgPath2);
					$(this).css({backgroundImage: "url()", filter:" progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='"+imgPath2+"')"});
				}
			});
		}
				
		//Call Function
		pngFix();
	}
	
	
	//---------- Effects Functions ---------

	//Make Link Cursor Function
	function makeLink(makeLink){
		$(makeLink).hover(function(){
			$(this).css({cursor:'pointer'});
		}, function(){
		});
	}
	
	//Opacity Hover Function
	function hoverOpacity(hoverThis, hoverStart, hoverEnd){
		//Set initial opacity
		$(hoverThis).css({opacity:hoverStart});
		//Opacity hover function
		$(hoverThis).hover(function(){
			$(this).css({opacity:hoverEnd});
		}, function(){
			$(this).css({opacity:hoverStart});
		});
	}
	
	//Background Hover Function
	function hoverBack(hoverThis){
		//Background hover function
		$(hoverThis).hover(function(){
			$(this).css({backgroundPosition:'bottom'});
		}, function(){
			$(this).css({backgroundPosition:'top'});
		});
	}
	
	//Underline Hover Function
	function hoverUnderline(hoverThis){
		//Background hover function
		$(hoverThis).hover(function(){
			$(this).css({textDecoration:'none'});
		}, function(){
			$(this).css({textDecoration:'underline'});
		});
	}
	
	//Underline Hover Function
	function hoverLine(hoverThis){
		//Background hover function
		$(hoverThis).hover(function(){
			$(this).css({textDecoration:'underline'});
		}, function(){
			$(this).css({textDecoration:'none'});
		});
	}
	
	//Colour Hover Function
	function hoverColour(hoverThis){
		//Background hover function
		$(hoverThis).hover(function(){
			$(this).css({color:'#69bff5'});
		}, function(){
			$(this).css({color:'#a8a8a8'});
		});
	}
	
	//Colour Hover Function
	function hoverBack(hoverThis){
		//Background hover function
		$(hoverThis).hover(function(){
			$(this).css({backgroundPosition:'bottom'});
		}, function(){
			$(this).css({backgroundPosition:'top'});
		});
	}
	
	//Colour Hover Function
	function hoverBackColor(hoverThis, colourOver, colourOut, hoverOddEven){
		$(hoverThis).hover(function(){
			$(this).css({backgroundColor:colourOver});
		}, function(){
			$(this).css({backgroundColor:colourOut});
			if(hoverOddEven == 'yes'){
				$(hoverThis+':odd').css({backgroundColor:'#f8f7fb'});
				$(hoverThis+':even').css({backgroundColor:'#FFFFFF'});
			}
		});
	}

//---------- UNIVERSAL BOTTOM ------------------------------------------------------------------------------------
	
	//Hand Cursor Hover
	$('.newsCat, .slideNo, .slideNav, .topModalBtn, .makeLink').hover(function(){
		$(this).css({cursor:'pointer'});
	}, function(){
	});
	
	//Background movement hover
	$('.newsCat').hover(function(){
		$(this).css({backgroundPosition:'bottom'});
	}, function(){
		$(this).css({backgroundPosition:'top'});
	});
	
	//Opacity hover
	$('.slideNav').hover(function(){
		$(this).css({opacity:1});
	}, function(){
		$(this).css({opacity:opacityLow});
	});

});

//--------- ONCE PAGE IS LOADED ----------------------------------------------------------------------------------

$(window).bind('load', function() {
	
	//Load up large banner images only once the rest of the page is done
	var slideNo = 0;
	$('.slidePane').each(function(){
		slideNo++;
		$(this).addClass('slide' + slideNo);
	});
	
});