maskHeight = 1;
portfolioSelectedNum = 1;
portfolioArray = ['argosy-cable.jpg','hair-beauty-2u.jpg','heaton-homes.jpg','nannys-kitchen.jpg','policy-central.jpg','rupert-marlow.jpg','timbercraft.jpg'];
portfolioNotesHeadingArray = ['argosy','hair & beauty 2u','heaton homes','nannys kitchen','policy central','rupert marlow','timbercraft'];
portfolioNotesTextArray = ["The website built for Argosy was built to replace an exitsing eShop and bring such improvments as product search, multiple currencies, featured products, product options and more including latest news and special offers, all controllable from a secure Admin Zone. They were delighted with the new web solution and their website usage has grown hugely since the improvements.","Hair & Beauty 2U was produced as a retail based eShop to sell hair and beauty products to the end consumer. The eShop contains innovative features such as alerting the website owner when a search has been made and produces no results. They now have an new, loyal customer base from this new business arm, bringing a great ROI each month.","We suggested to Heaton Homes, an existing client of ours that their website could do with an overhaul to modernise it, they agreed and left it in our capable hands. We produced a much more modern design for them, including an animated homepage and a latest news system, consulting them at various stages of the design & build. They were very pleased from the new website which went live smoothly.","This website was produced for a client who wanted a small but effective website to show off her cake making skills to customers new and existing including an interactuive Flash gallery. They have been using social marketing to draw new users to the website and are looking to make further improvements to it in the near future.","Policy Central is a solution we have produced in-house to meet the needs of our clients who want to manage their business policy compliance online. The solution allows for document delivery and quizzes to help ensure employees understand the policies correctly. We continue to have many new clients sign up for the service and continue to improve the solution to provide extra benefits and features to our happy clients.","Rupert came to us to produce not only a high quality solution for him to showcase his talents, but also build a fantastic photo ordering system. We built an Admin Zone allowing him to upload and manage photo albums and an interactive system for users to order their photos behind a password protected login screen. Rupert was delighted with the website and is looking to produce more websites like this.","Timbercraft approached us for a new website to showcase the range of high quality kitchen, bathroom & bedroom products they have in their stores. We produced a design to match their branding and display examples of their products in an effective, well presented fashion. Timbercraft were delighted with the website and are looking to make improvements to it and use the website as an effective online marketing tool."];
portfolioLargeImageSlide = -735;
portfolioNotesSlide = -110;
clientZonePosition = "off";

function portfolio(maskName) {
		window.location = "#";
		maskName = "blackMask";
		document.body.style.overflow = "hidden";
		document.getElementById(maskName).style.height = "1%";
		document.getElementById(maskName).style.display = "block";
		intInterval = setInterval ("moveMask('"+maskName+"')", 30);
}

function moveMask(maskName) {
	maskHeight += (100-maskHeight)/4;
	if (maskHeight > 99.9) {
		maskHeight = 100;
		document.getElementById(maskName).style.height = "100%";
		document.getElementById('portfolioDiv').style.display = "block";
		clearInterval(intInterval);
	} else {
		document.getElementById(maskName).style.height = maskHeight+"%"
	};
}

function resetMask(maskName) {
	maskName = "blackMask";
	maskHeight = 1;
	document.body.style.overflow = "auto";
	document.getElementById(maskName).style.display = "none";
	document.getElementById('portfolioDiv').style.display = "none";
	document.getElementById(maskName).style.height = "100%"
}

function setStartPortfolioExample() {
	document.getElementById('portfolioLargeImageSlideImg').src="portfolio/"+portfolioArray[0];
	document.getElementById('portfolioNotesStatic').innerHTML = "<h1 class='headingLineHeight alignLeft white'>"+portfolioNotesHeadingArray[0]+"</h1><p class='lineHeight alignLeft white'>"+portfolioNotesTextArray[0]+"</p>";
}

function selectPortfolioNav(portfolioType,portfolioNavNum,setNewSelectedNum) {
	if (portfolioLargeImageSlide==-735) {
		if (setNewSelectedNum&&setNewSelectedNum!=portfolioSelectedNum) {
			document.getElementById(portfolioType+'NavHighlight'+portfolioSelectedNum).className="portfolioNavOptionHighlightNotSel";
			portfolioSelectedNum=setNewSelectedNum;
			document.getElementById('portfolioLargeImageSlideImg').src="/portfolio/"+portfolioArray[portfolioNavNum-1];
			document.getElementById('portfolioLargeImageSlideImg').onload = function() {
				document.getElementById(portfolioType+'NavHighlight'+portfolioSelectedNum).className="portfolioNavOptionHighlight";
				intIntervalImg = setInterval ("movePortfolioImageSlide()", 30);
			}
		}
		for (i=1;i<=7;i++) {
			if (i==portfolioSelectedNum||i==portfolioNavNum) {
				document.getElementById(portfolioType+'NavHighlight'+i).className="portfolioNavOptionHighlight";
			} else {
				if (document.getElementById(portfolioType+'NavHighlight'+i).className="portfolioNavOptionHighlight") {
					document.getElementById(portfolioType+'NavHighlight'+i).className="portfolioNavOptionHighlightNotSel";
				}
			}
			if (i==portfolioSelectedNum) {
				document.getElementById(portfolioType+'NavHighlightImg'+i).style.cursor = "default";
			} else {
				document.getElementById(portfolioType+'NavHighlightImg'+i).style.cursor = "pointer";
			}
		}
	}
}

function movePortfolioImageSlide() {
	portfolioLargeImageSlide += (0-portfolioLargeImageSlide)/4;
	if (portfolioLargeImageSlide > -1) {
		document.getElementById('portfolioLargeImageSlideImg').style.left = "0px";
		document.getElementById('portfolioLargeImage').src=document.getElementById('portfolioLargeImageSlideImg').src;
		document.getElementById('portfolioLargeImageSlideImg').style.left = "-735px";
		portfolioLargeImageSlide = -735;
		clearInterval(intIntervalImg);
		document.getElementById('portfolioNotesSlide').innerHTML = "<h1 class='headingLineHeight alignLeft white'>"+portfolioNotesHeadingArray[portfolioSelectedNum-1]+"</h1><p class='lineHeight alignLeft white'>"+portfolioNotesTextArray[portfolioSelectedNum-1]+"</p>";
		intIntervalNotes = setInterval ("movePortfolioNotesSlide()", 30);
	} else {
		document.getElementById('portfolioLargeImageSlideImg').style.left = portfolioLargeImageSlide + "px";
	}
}

function movePortfolioNotesSlide() {
	portfolioNotesSlide += (0-portfolioNotesSlide)/4;
	if (portfolioNotesSlide > -1) {
		document.getElementById('portfolioNotesStatic').style.top = "0px";
		document.getElementById('portfolioNotesStatic').innerHTML = "<h1 class='headingLineHeight alignLeft white'>"+portfolioNotesHeadingArray[portfolioSelectedNum-1]+"</h1><p class='lineHeight alignLeft white'>"+portfolioNotesTextArray[portfolioSelectedNum-1]+"</p>";
		document.getElementById('portfolioNotesSlide').style.top = "-110px";
		portfolioNotesSlide = -110;
		clearInterval(intIntervalNotes);
	} else {
		document.getElementById('portfolioNotesSlide').style.top = portfolioNotesSlide + "px";
		document.getElementById('portfolioNotesStatic').style.top = (portfolioNotesSlide+110) + "px";
	}
}

function closeButton(direction) {
	if(direction=="up") {
		document.getElementById('portfolioCloseButton').src="/images/close-button-2.png";
	} else {
		document.getElementById('portfolioCloseButton').src="/images/close-button.png";
	}
}

function clientZone() {
	if(clientZonePosition=="off") {
		clientLoginBoxYPos = -125;
		document.getElementById("kbaseClientZoneLogin").style.zIndex = 100;
	} else {
		clientLoginBoxYPos = 0;
	};
	intIntervalClient = setInterval ("moveClientZone()", 30);
}

function moveClientZone() {
	if(clientZonePosition=="off") {
		clientLoginBoxYPos -= (clientLoginBoxYPos/4);
	} else {
		clientLoginBoxYPos -= ((125+clientLoginBoxYPos)/4);
	}
	if (clientLoginBoxYPos > -0.1 && clientZonePosition=="off") {
		clientLoginBoxYPos = 0;
		clientZonePosition="on";
		document.getElementById("clientLoginBox").style.top = "0px";
		document.getElementById("clientLoginButton").style.top = "-1px";
		clearInterval(intIntervalClient);
	} else {
		if (clientLoginBoxYPos < -124.9 && clientZonePosition=="on") {
			clientLoginBoxYPos = 0;
			clientZonePosition="off";
			document.getElementById("clientLoginBox").style.top = "-125px";
			document.getElementById("clientLoginButton").style.top = "-126px";
			document.getElementById("kbaseClientZoneLogin").style.zIndex = 1;
			clearInterval(intIntervalClient);
		} else {
			document.getElementById("clientLoginBox").style.top = clientLoginBoxYPos + "px";
			document.getElementById("clientLoginButton").style.top = (clientLoginBoxYPos-1) + "px";
		}
	};
}

// Twitter display functions
String.prototype.linkify = function() {
 return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) { return m.link(m); });
};
 
function relative_time(time_value) {
 var values = time_value.split(" ");
 time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
 var parsed_date = Date.parse(time_value);
 var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
 var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
 delta = delta + (relative_to.getTimezoneOffset() * 60);
   
 var r = '';
 if (delta < 60) {
 r = 'a minute ago';
  } else if(delta < 120) {
 r = 'couple of minutes ago';
  } else if(delta < (45*60)) {
 r = (parseInt(delta / 60)).toString() + ' minutes ago';
  } else if(delta < (90*60)) {
 r = 'an hour ago';
  } else if(delta < (24*60*60)) {
 r = '' + (parseInt(delta / 3600)).toString() + ' hours ago';
  } else if(delta < (48*60*60)) {
 r = '1 day ago';
  } else {
 r = (parseInt(delta / 86400)).toString() + ' days ago';
  }
 
 return r;
}
 
function twitter_callback() { return true; }

function CheckForm()
{
	var success = true;
	var msg = "";
	if (document.eNews.emailENewsSubScribe.value.length == 0)
	{
		msg += 'Sorry, but you havent yet entered your email address';
		success = false;
	}
	else if (echeck(document.eNews.emailENewsSubScribe.value) == "") {
		success = false
		msg += "Sorry, but you haven't entered a valid email address"
	}
	if(success==false) alert(msg);
	document.returnValue = success; 
}

function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    return false
	 }
		
	 if (str.indexOf(" ")!=-1){
	    return false
	 }

	 return true;				
}
