// Chrobis main page animations - chrobisEffects.js
//
// Copyright (c) 2008 Chrobis
// Created: 24/07/2009

//
// Universal page events
//
// MooTools
var menuSlide;
var sizer;
var defaultScroll;
var myScrollbar;

var keyStrokes = function(event) {
	if (defaultScroll == 'mainContentContainer' && (event.key == "down" || event.key == "up"
		|| event.code == "36" || event.code == "35" || event.code == "34" || event.code == "33")) {
		if (event.preventDefault) event.preventDefault( );
      else event.returnValue = false;

		Event.Keys.home = 36;
		Event.Keys.end = 35;
		Event.Keys.pageUp = 33;
		Event.Keys.pageDown = 34;
		if (event.key == "up") {  
			myScrollbar.scrollVertical(-20); 
		} else if (event.key == "down") {  
			myScrollbar.scrollVertical(20); 
		} else if (event.key == "space") {  
		   myScrollbar.scrollVertical($('mainContentContainer').clientHeight);
		} else if (event.code == "36") {  
			myScrollbar.scrollVertical(-($('mainContentContainer').getScrollSize().y));
	    } else if (event.code == "35") {  
			myScrollbar.scrollVertical($('mainContentContainer').getScrollSize().y);
	    } else if (event.code == "33") {  
			myScrollbar.scrollVertical(-($('mainContentContainer').clientHeight));
	    } else if (event.code == "34") {  
			myScrollbar.scrollVertical($('mainContentContainer').clientHeight);
	    }
	}
}

var keyStrokesCancel = function(event) {
	myScrollbar.stopScrolling(event);
}

//var adImageList = array('200908001-boostsales.png', '200908002-daviddavis.png', '200908003-itsupport.png', '200908004-businessingear.png');
var adTextList = new Array('<h1>We can help.</h1><p>We\'re experts at making websites that create new business.</p>Click <a href="webdesign">here</a> for more details, or click <a href="contact">here</a> to ask us what we can do for you.</p>',
			'<h1>We can help.</h1><p>Our work makes a difference.</p><p>MP David Davis recognised that - <a href="contact">drop us a line</a> and see what we can do for you.</p>',
			'<h1>We can help.</h1><p>Don\'t let computers drive you up the wall. Let us take care of your IT support.</p><p>Click <a href="support">here</a> for details.</p>',
			'<h1>We can help.</h1><p>We can revolutionise your IT to do your work for you. E-commerce, customer relationship management, accounting and invoicing: you name it, we can do it.</p><p>Click <a href="business">here</a> for details.</p>');

var adCaptionList = new Array('Boost your sales leads and increase profits',
			'We can help you make an impact.',
			'Or you could give us a call.',
			'Accelerate your business into top gear.');

MySlide = new Class({
	Extends: Fx.Slide,
	 
	initialize: function(element,options) {
		this.parent(element,options);
		if(this.options.mode == 'horizontalRtL'){
			this.wrapper.setStyle('float','right');
			this.wrapper.setStyle('height','100%');
			this.extraWrapper = new Element('div',{
				styles: {
					overflow: 'hidden',
					height: '100%'
				}
			}).wraps(this.wrapper);    
		}
	},
	 
	horizontalRtL: function() {
		this.margin = 'margin-right';
		this.layout = 'width';
		this.offset = this.element.offsetWidth;
	}
});

window.addEvent('domready', function(){
	var contentHolder = $('contentAreaHolder');
	if (document.referrer.substring(0, siteUrl.length) != siteUrl) {
	   if(!Browser.Engine.trident) {
	      var siteControlsHolder = $('siteControlsHolder');
         var newsletter = $('newsletter');
         var contactDetails = $('contactDetails');
      
         siteControlsHolder.set('opacity', 0);
         newsletter.set('opacity', 0);
         contactDetails.set('opacity', 0);
      
         showControls = new Fx.Tween(siteControlsHolder, {property: 'opacity', duration: 800, transition: 'quad:out'});
         showNewsletter = new Fx.Tween(newsletter, {property: 'opacity', delay: 600, duration: 800, transition: 'quad:out'});
         showContacts = new Fx.Tween(contactDetails, {property: 'opacity', duration: 800, transition: 'quad:out'});
      
         contentHolder.set('opacity', 0);
         contentHolder.style.display = "block"; 
         showContent = new Fx.Tween(contentHolder, {property: 'opacity', duration: 1500, transition: 'quad:out'});
	   }   
		
		menuSlide = new MySlide('menuSlider', {mode: 'horizontalRtL', transition: 'quint:out', duration: 1250});
		menuSlide.hide();
		
		if(!Browser.Engine.trident) {
   		var startNewsletter = function(){
   			showNewsletter.start(0, 1);
   		}
   		
   		var startContacts = function(){
   			showContacts.start(0, 1);
   		}
   		
   		var startChain = function(){showContent.start(0, 1).chain(
   				function(){menuSlide.toggle().chain(
   						function(){
   							showControls.start(0, 1);
   							startNewsletter.delay(600);
   							startContacts.delay(1200);
   						}
   				);}
   		);}
   		startChain.delay(900, this);
		} else {
		   $('menuArea').style.display = 'block';
		   menuSlide.toggle();
		}
	} else {
	   $('menuArea').style.display = 'block';
		contentHolder.style.display = "block";
	}
	
	
	if($('mainContentHolder')) {
		if (!(Browser.Engine.trident) || navigator.userAgent.toLowerCase().indexOf('msie 8.0') > -1) {
			/*  */
         myScrollbar = new UvumiScrollbar('mainContentContainer'); 
         var mainContent = $('mainContentContainer');
         mainContent.onmouseover = function(){defaultScroll = this.id;};
         mainContent.onmouseout = function(){defaultScroll = "";};
         document.addEvent('keydown', keyStrokes);
         document.addEvent('keyup', keyStrokesCancel);
		}
	}
	
	setTimeout("myScrollbar.update()",500);
});

window.addEvent('resize', function(){
	if (!(Browser.Engine.trident) || navigator.userAgent.toLowerCase().indexOf('msie 8.0') > -1) {
		/*   */
      setTimeout("myScrollbar.update()",100);
	}
});

function sN() {
	if (!(Browser.Engine.trident) || navigator.userAgent.toLowerCase().indexOf('msie 8.0') > -1) {
		$('newsletterBoxHolder').style.display = 'table';
	} else {
		$('newsletterBoxHolder').style.display = 'block';
	}
}

function hideNewsletter() {
	$('newsletterBoxHolder').style.display = 'none';
}

function newsletterSignUp() {
	var form = document.newsletterForm;
	var params = "name=" + form.newsName.value + "&email=" + form.newsEmail.value;
   var myRequest = new Request.HTML({
		url: siteUrl + '/newsletterDispatcher.php',
		onSuccess: function(){
   		alert('Newsletter request made!');
   		hideNewsletter();
		}
	}).send(params);
}

//
// Button highlighting
//

// Variables for buttons
var swapFacebookIcon = new Array(siteUrl + "/images/facebookIcon.png", siteUrl + "/images/facebookIconOver.png");
var swapTwitterIcon = new Array(siteUrl + "/images/twitterIcon.png", siteUrl + "/images/twitterIconOver.png");
var swapHomeMenuButton = new Array(siteUrl + "/images/homeMenu.png", siteUrl + "/images/homeMenuOver.png");
var swapSitesMenuButton = new Array(siteUrl + "/images/sitesMenu.png", siteUrl + "/images/sitesMenuOver.png");
var swapServicesMenuButton = new Array(siteUrl + "/images/servicesMenu.png", siteUrl + "/images/servicesMenuOver.png");
var swapBlogMenuButton = new Array(siteUrl + "/images/blogMenu.png", siteUrl + "/images/blogMenuOver.png");
var swapContactMenuButton = new Array(siteUrl + "/images/contactMenu.png", siteUrl + "/images/contactMenuOver.png");
var swapContactSubmitButton = new Array(siteUrl + "/images/submit.png", siteUrl + "/images/submitOver.png");

function ieHighlightButton() {
}

function ieRemoveHighlightButton() {
	
}

function highlightButton(button, swapImages) {
	button.src = swapImages[1];
}

function removeHighlightButton(button, swapImages) {
	button.src = swapImages[0];
}

function startSwitcher() {
}

function showAdvert(num) {
	$('advertImage1').style.display = 'none';
	$('advertSelector1').className = 'advertOptionSelector';
	$('advertImage2').style.display = 'none';
	$('advertSelector2').className = 'advertOptionSelector';
	$('advertImage3').style.display = 'none';
	$('advertSelector3').className = 'advertOptionSelector';
	$('advertImage4').style.display = 'none';
	$('advertSelector4').className = 'advertOptionSelector';
	$(eval("'" + 'advertImage' + num + "'")).style.display = 'block';
	$(eval("'" + 'advertSelector' + num + "'")).className = 'advertOptionSelector activeSelector';
	$('advertText').innerHTML = adTextList[num - 1];
	$('advertCaption').innerHTML = adCaptionList[num - 1];
}

function showPortfolioDetail() {
   $('portfolio').style.display = 'block';
}

function hidePortfolioDetail() {
   $('portfolio').style.display = 'none';
}

//Portfolio page
portfolioArray = new Array(); 
portfolioArray[0] = "<table><tr><td>Client Name:</td><td>Mirfield Town Council</td></tr><tr><td>Business Industry:</td><td>Local Government Authority</td></tr><tr><td>Location:</td><td>Mirfield, West Yorkshire</td></tr><tr><td>Completed:</td><td>November 2008</td><tr><td>Description:</td><td>The Council decided that in order to keep up with recent technology and communication methods to establish an online portal of local information for their residents to access whilst also making it easier for the residents to contact those elected to serve on their behalf.</td></tr><tr><td>The Client says:</td><td></td></tr><tr><td>Website:</td><td><a href=\"http://www.mirfieldtowncouncil.gov.uk\">http://www.mirfieldtowncouncil.gov.uk</a></td></tr></table>";
portfolioArray[1] = "<table><tr><td>Client Name:</td><td>Louise</td></tr><tr><td>Business Industry:</td><td>Interior Design</td></tr><tr><td>Location:</td><td>Solihull, West Midlands</td></tr><tr><td>Completed:</td><td>February 2008</td><tr><td>Description:</td><td>A small team of interior designers asked for a bespoke website based on their existing brochure design that they were already using and an existing brand that they were happy with, but also showed off examples of their work using a custom-built gallery area.</td></tr><tr><td>The Client says:</td><td></td></tr><tr><td>Website:</td><td><a href=\"http://www.joaldesigns.co.uk\">http://www.joaldesigns.co.uk</a></td></tr></table>";
portfolioArray[2] = "<table><tr><td>Client Name:</td><td>David</td></tr><tr><td>Business Industry:</td><td>Politics</td></tr><tr><td>Location:</td><td>Haltemprice and Howden, UK</td></tr><tr><td>Completed:</td><td>July 2008</td><tr><td>Description:</td><td>Our client required an immediate overhaul of their existing brand and website design within a 48 hour period and the relaunch of the site was integrated with further Web 2.0 technology to promote the client's cause to online social media and related groups.</td></tr><tr><td>The Client says:</td><td></td></tr><tr><td>Website:</td><td><a href=\"http://www.daviddavisforfreedom.com\">http://www.daviddavisforfreedom.com</a></td></tr></table>";
portfolioArray[3] = "<table><tr><td>Client Name:</td><td>Tim</td></tr><tr><td>Business Industry:</td><td>Travel, Transportation and Leisure</td></tr><tr><td>Location:</td><td>London, UK</td></tr><tr><td>Completed:</td><td>October 2008</td><tr><td>Description:</td><td>The society required an overhaul of their existing website brand and a reorganisation of their information, and further upgrades allowed for an expansion to their member's area to allow for greater numbers to join. More recent modules have been added to allow their staff to manage their members far quicker than previously.</td></tr><tr><td>The Client says:</td><td></td></tr><tr><td>Website:</td><td><a href=\"http://www.revenuemanagement.org.uk\">http://www.revenuemanagement.org.uk</a></td></tr></table>";
portfolioArray[4] = "<table><tr><td>Client Name:</td><td>Colin and Sandra</td></tr><tr><td>Business Industry:</td><td>Property Management</td></tr><tr><td>Location:</td><td>Orlando, FL USA</td></tr><tr><td>Completed:</td><td>November 2008</td><tr><td>Description:</td><td>Managing approximately 50 rental villas in and around the Orlando area, our client required a complete overhaul and rebrand of their existing site. A second phase has seen the integration of a number of management tools behind the scenes on the website, allowing them to manage all of their properties, bookings and service companies through one integrated system.</td></tr><tr><td>The Client says:</td><td></td></tr><tr><td>Website:</td><td><a href=\"http://www.villa4uflorida.com\">http://www.villa4uflorida.com</a></td></tr></table>";
portfolioArray[5] = "<table><tr><td>Client Name:</td><td>Catherine</td></tr><tr><td>Business Industry:</td><td>Charity</td></tr><tr><td>Location:</td><td>Chester, UK</td></tr><tr><td>Due:</td><td>Very soon!</td><tr><td>Description:</td><td>Catherine approached Chrobis asking for help with setting up a website for her charity which provides a supportive network and information for parents who have severely disabled children. Chrobis was only too willing to lend a hand for such a worthy cause, particularly due to the charity's financial constraints, and the site is due to go live very soon.</td></tr><tr><td>The Client says:</td><td></td></tr><tr><td>Website:</td><td><a href=\"http://www.mumschums.co.uk\">http://www.mumschums.co.uk</a></td></tr></table>";
portfolioArray[6] = "<table><tr><td>Client Name:</td><td>Izzy and Tracey</td></tr><tr><td>Business Industry:</td><td>Health and Fitness</td></tr><tr><td>Location:</td><td>Chester, UK</td></tr><tr><td>Completed:</td><td>December 2008</td><tr><td>Description:</td><td>A duo of bone density testers required an online presence for their marketing and promotional material as their work takes them to gyms and higher education facilities all across the UK to perform testing days and highlighting the increasing problem of osteoporosis</td></tr><tr><td>The Client says:</td><td></td></tr><tr><td>Website:</td><td><a href=\"http://www.bonematters.co.uk\">http://www.bonematters.co.uk</a></td></tr></table>";
portfolioArray[7] = "<table><tr><td>Client Name:</td><td>Anthony and Simon</td></tr><tr><td>Business Industry:</td><td>Building Contractors</td></tr><tr><td>Location:</td><td>Solihull, West Midlands</td></tr><tr><td>Completed:</td><td>March 2008</td><tr><td>Description:</td><td>Using their existing brand, Anthony and Simon asked us to create a brand new online presence for their business to be included in their new marketing material and also to advertise to a wider range of clients outside their local area and current market range.</td></tr><tr><td>The Client says:</td><td></td></tr><tr><td>Website:</td><td><a href=\"http://www.touchwoodbuilding.co.uk\">http://www.touchwoodbuilding.co.uk</a></td></tr></table>";
portfolioArray[8] = "<table><tr><td>Client Name:</td><td>Ruth</td></tr><tr><td>Business Industry:</td><td>Complementary Therapies</td></tr><tr><td>Location:</td><td>Worcester, UK</td></tr><tr><td>Completed:</td><td>Novemeber 2009</td><tr><td>Description:</td><td>A self-employed aromatherapist asked us to create a site for her so that she could advertise the different styles of complementary therapies and natural remedies that she offers, whilst also having the facility for her clients to order her books online that are currently available.</td></tr><tr><td>The Client says:</td><td></td></tr><tr><td>Website:</td><td><a href=\"http://www.aroma-reiki.com\">http://www.aroma-reiki.com</a></td></tr></table>";
portfolioArray[9] = "<table><tr><td>Client Name:</td><td>Free To Live Leeds</td></tr><tr><td>Business Industry:</td><td>Social Welfare</td></tr><tr><td>Location:</td><td>Leeds, UK</td></tr><tr><td>Completed:</td><td>December 2009</td><tr><td>Description:</td><td>A non-profit volunteer social enterprise scheme of personal budgets users, who meet regularly to offer peer support and would like to extend the network to help others in the local area, by providing them with an online forum and resource to find out information about social care support in Leeds.</td></tr><tr><td>The Client says:</td><td></td></tr><tr><td>Website:</td><td><a href=\"http://www.freetoliveleeds.org\">http://www.freetoliveleeds.org</a></td></tr></table>";
portfolioArray[10] = "<table><tr><td>Client Name:</td><td>Barn Boutique</td></tr><tr><td>Business Industry:</td><td>Retail Outlet</td></tr><tr><td>Location:</td><td>Wrexham, UK</td></tr><tr><td>Completed:</td><td>September 2010</td><tr><td>Description:</td><td>Barn Boutique sells a range of gifts and accessories for women. They stock Charlotte's Garden, Emreco as well as gift sets, hats, snugglies, hangers, hot water bottles and other great products.</td></tr><tr><td>The Client says:</td><td></td></tr><tr><td>Website:</td><td><a href=\"http://www.barnboutique.co.uk\">http://www.barnboutique.co.uk</a></td></tr></table>";

portfolioTitle = new Array(); 

portfolioTitle[0] = "Mirfield Town Council";
portfolioTitle[1] = "Joal Designs";
portfolioTitle[2] = "David Davis";
portfolioTitle[3] = "Revenue Management Society";
portfolioTitle[4] = "Villa4UFlorida";
portfolioTitle[5] = "Mum's Chums";
portfolioTitle[6] = "Bone Matters";
portfolioTitle[7] = "Touchwood Building Contractors";
portfolioTitle[8] = "Aroma Reiki";
portfolioTitle[9] = "Free To Live Leeds";
portfolioTitle[10] = "Barn Boutique";

function showText(number) {
   $('portfolio').style.display = 'block';
   var theTitle = $("portfolioTitle"); {
      $('portfolioTitle').innerHTML = portfolioTitle[number];
   }
   var theText = $("portfolioDescription"); {
      $('portfolioDescription').innerHTML = portfolioArray[number];
   }
}  
