var Logos = function () {
	var Slideshow = new noobSlide({ box: $('noob1'), items: [0,1,2,3,4,5], size: 923, autoPlay: true, interval: 5000,
			fxOptions: { duration: 750, transition: Fx.Transitions.Quad.easeInOut, wait: false } });
}

var Form = function () {
	var form_send = $('form-send');
	$('form-send').addEvent('mouseenter', function(){ form_send.setStyle('background-position', '0px -18px'); });
	$('form-send').addEvent('mouseleave', function(){ form_send.setStyle('background-position', '0px 0px'); });
}

var Portfolio = function () {
	
	var windowSize = window.getSize();
	var actualWindowSize = windowSize.y;
	var one = 397 - ((actualWindowSize - 251) / 2);
	var oneStart = 1557-actualWindowSize;
	if (oneStart < one) { var one = oneStart }
	var oneScroll = function () {
		var myFx = new Fx.Scroll(window, {
			offset: {
				'y': one
			},
			duration: 750,
			transition: Fx.Transitions.Quad.easeOut
		}).toTop();
	}
	$$('a.one').addEvent('click', oneScroll);
	
	var windowSize = window.getSize();
	var actualWindowSize = windowSize.y;
	var two = 666 - ((actualWindowSize - 251) / 2);
	var twoStart = 1557-actualWindowSize;
	if (twoStart < two) { var two = twoStart }
	var twoScroll = function () {
		var myFx = new Fx.Scroll(window, {
			offset: {
				'y': two
			},
			duration: 750,
			transition: Fx.Transitions.Quad.easeOut
		}).toTop();
	}
	$$('a.two').addEvent('click', twoScroll);
	
	var windowSize = window.getSize();
	var actualWindowSize = windowSize.y;
	var three = 935 - ((actualWindowSize - 251) / 2);
	var threeStart = 1557-actualWindowSize;
	if (threeStart < three) { var three = threeStart }
	var threeScroll = function () {
		var myFx = new Fx.Scroll(window, {
			offset: {
				'y': three
			},
			duration: 750,
			transition: Fx.Transitions.Quad.easeOut
		}).toTop();
	}
	$$('a.three').addEvent('click', threeScroll);
	
	var windowSize = window.getSize();
	var actualWindowSize = windowSize.y;
	var four = 1204 - ((actualWindowSize - 251) / 2);
	var fourStart = 1557-actualWindowSize;
	if (fourStart < four) { var four = fourStart }
	var fourScroll = function () {
		var myFx = new Fx.Scroll(window, {
			offset: {
				'y': four
			},
			duration: 750,
			transition: Fx.Transitions.Quad.easeOut
		}).toTop();
	}
	$$('a.four').addEvent('click', fourScroll);
	
}

/*	var windowSize = window.getSize();
	var actualWindowSize = windowSize.y;
	var portfolioStart = 1454-actualWindowSize;
	if (portfolioStart > 710) { var portfolioStart = 710 }
	var logoScroll = function () {
		var myFx = new Fx.Scroll(window, {
			offset: {
				'y': portfolioStart
			},
			duration: 750,
			transition: Fx.Transitions.Quad.easeOut
		}).toTop();
	}  */


window.addEvent('domready', function() {
	
	Logos();
	
	MiddleNav();
	
	Form();
	
	Portfolio();
	
});

var $j = jQuery.noConflict();

var moving = false;

$j(document).ready(function(){

	
	
	
	// Home - Turn on this light and turn off home light
	
	$j("#home").mouseover(function(){
	
		$j("#home > h2 > a").addClass("active");
		
		$j("#prices > h2 > a").removeClass("active");
	
	});
	
	// Home - Turn off this light and turn on home light
	
	$j("#home").mouseout(function(){
	
		$j("#home > h2 > a").removeClass("active");
		
		$j("#prices > h2 > a").addClass("active");
	
	});
	
	
	// Logo Design - Turn on this light and turn off home light
	
	$j("#logo-design").mouseover(function(){
	
		$j("#logo-design > h2 > a").addClass("active");
		
		$j("#prices > h2 > a").removeClass("active");
	
	});
	
	$j("#logo-design > h2 > a").mouseover(function(){
		
		$j("#logo-design > ul > li > h3 > a.portfolio-logo").stop().animate({height:'20px'},{queue:false, duration:1, easing: 'easeOutQuad'});
		
	});
	
	// Logo Design - Turn off this light and turn on home light
	
	$j("#logo-design").mouseout(function(){
	
		$j("#logo-design > h2 > a").removeClass("active");
		
		$j("#prices > h2 > a").addClass("active");
	
	});
	
	// Logo Design - Slide out ul
	
	$j("#logo-design > h2 > a").mouseover(function(){
												   
		$j("#logo-design > ul").stop().animate({height:'63px'},{queue:false, duration:250, easing: 'easeOutQuad'})
	
	});
	
	// Logo Design - Slide in ul
	
	$j("#logo-design > h2 > a").mouseout(function(){
	
		$j("#logo-design > ul").stop().animate({height:'0px'},{queue:false, duration:250, easing: 'easeOutQuad'});
	
	});
	
	// Logo Design Sub Links - Stop ul from sliding back in
	
	$j("#logo-design > ul > li > h3 > a").mouseover(function(){
												   
		$j("#logo-design > ul").stop().animate({height:'63px'},{queue:false, duration:250, easing: 'easeOutQuad'})
	
	});
	
	// Logo Design Sub Links - Slide in ul
	
	$j("#logo-design > ul > li > h3 > a").mouseout(function(){
	
		$j("#logo-design > ul").stop().animate({height:'0px'},{queue:false, duration:250, easing: 'easeOutQuad'})
	
	});
	
	// Logo Design Sub Overview Link - Slide out
	
	$j("#logo-design > ul > li > h3 > a.overview").mouseover(function(){
												   
		$j("#logo-design > ul > li > h3 > a.portfolio-logo").stop().animate({height:'20px'},{queue:false, duration:250, easing: 'easeOutQuad'});
	
	});
	
	// Logo Design Sub Portfolio Link - Slide out
	
	$j("#logo-design > ul > li > h3 > a.portfolio-logo").mouseover(function(){
												   
		$j("#logo-design > ul > li > h3 > a.portfolio-logo").stop().animate({height:'106px'},{queue:false, duration:250, easing: 'easeOutQuad'});
		
		$j("#logo-design > ul").stop().animate({height:'149px'},{queue:false, duration:250, easing: 'easeOutQuad'});
	
	});
	
	
	// Corporate Identity Design - Turn on this light and turn off home light
	
	$j("#corporate-identity-design").mouseover(function(){
	
		$j("#corporate-identity-design > h2 > a").addClass("active");
		
		$j("#prices > h2 > a").removeClass("active");
	
	});
	
	$j("#corporate-identity-design > h2 > a").mouseover(function(){
		
		$j("#corporate-identity-design > ul > li > h3 > a.portfolio-identity").stop().animate({height:'20px'},{queue:false, duration:1, easing: 'easeOutQuad'});
		
	});
	
	// Corporate Identity Design - Turn off this light and turn on home light
	
	$j("#corporate-identity-design").mouseout(function(){
	
		$j("#corporate-identity-design > h2 > a").removeClass("active");
		
		$j("#prices > h2 > a").addClass("active");
	
	});
	
	// Corporate Identity Design - Slide out ul
	
	$j("#corporate-identity-design > h2 > a").mouseover(function(){
												   
		$j("#corporate-identity-design > ul").stop().animate({height:'63px'},{queue:false, duration:250, easing: 'easeOutQuad'})
	
	});
	
	// Corporate Identity Design - Slide in ul
	
	$j("#corporate-identity-design > h2 > a").mouseout(function(){
	
		$j("#corporate-identity-design > ul").stop().animate({height:'0px'},{queue:false, duration:250, easing: 'easeOutQuad'});
	
	});
	
	// Corporate Identity Design Sub Links - Stop ul from sliding back in
	
	$j("#corporate-identity-design > ul > li > h3 > a").mouseover(function(){
												   
		$j("#corporate-identity-design > ul").stop().animate({height:'63px'},{queue:false, duration:250, easing: 'easeOutQuad'})
	
	});
	
	// Corporate Identity Design Sub Links - Slide in ul
	
	$j("#corporate-identity-design > ul > li > h3 > a").mouseout(function(){
	
		$j("#corporate-identity-design > ul").stop().animate({height:'0px'},{queue:false, duration:250, easing: 'easeOutQuad'})
	
	});
	
	// Corporate Identity Design Sub Overview Link - Slide out
	
	$j("#corporate-identity-design > ul > li > h3 > a.overview").mouseover(function(){
												   
		$j("#corporate-identity-design > ul > li > h3 > a.portfolio-identity").stop().animate({height:'20px'},{queue:false, duration:250, easing: 'easeOutQuad'});
	
	});
	
	// Corporate Identity Design Sub Portfolio Link - Slide out
	
	$j("#corporate-identity-design > ul > li > h3 > a.portfolio-identity").mouseover(function(){
												   
		$j("#corporate-identity-design > ul > li > h3 > a.portfolio-identity").stop().animate({height:'106px'},{queue:false, duration:250, easing: 'easeOutQuad'});
		
		$j("#corporate-identity-design > ul").stop().animate({height:'149px'},{queue:false, duration:250, easing: 'easeOutQuad'});
	
	});
	
	
	// Contact - Turn on this light and turn off home light
	
	$j("#contact").mouseover(function(){
	
		$j("#contact > h2 > a").addClass("active");
		
		$j("#prices > h2 > a").removeClass("active");
	
	});
	
	// Contact - Turn off this light and turn on home light
	
	$j("#contact").mouseout(function(){
	
		$j("#contact > h2 > a").removeClass("active");
		
		$j("#prices > h2 > a").addClass("active");
	
	});
	
	
	
	$j('#nav a')
	.css( {backgroundPosition: "0px 0px"} )
	.mouseover(function(){
		$j(this).stop()
			.animate(
				{backgroundPosition:"(-15px 0px)"},
				{duration:125})
			.animate(
				{backgroundPosition:"(-15px -39px)"},
				{duration:5})
			.animate(
				{backgroundPosition:"(0px -39px)"},
				{duration:125})
			})
	.mouseout(function(){
		$j(this).stop()
			.animate(
				{backgroundPosition:"(-15px -39px)"},
				{duration:125})
			.animate(
				{backgroundPosition:"(-15px 0px)"},
				{duration:5})
			.animate(
				{backgroundPosition:"(0px 0px)"},
				{duration:125})
		})
	
	
	
});

var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function trim(s)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}
function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
var bracket=3
strPhone=trim(strPhone)
if(strPhone.indexOf("+")>1) return false
if(strPhone.indexOf("-")!=-1)bracket=bracket+1
if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false
var brchr=strPhone.indexOf("(")
if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false
if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}


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){
		   alert("Please include a valid E-mail Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please include a valid E-mail Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please include a valid E-mail Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please include a valid E-mail Address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please include a valid E-mail Address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please include a valid E-mail Address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Please include a valid E-mail Address")
		    return false
		 }

 		 return true					
	}


function checksubmit()

{if (document.enquire.Name.value == "")

{  alert("Please include your Name.")

  document.enquire.Name.focus()

  return false} 

  

var emailID=document.enquire.Email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please include your E-mail Address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.focus()
		return false
	}
	

var Phone=document.enquire.Phone
	
	if ((Phone.value==null)||(Phone.value=="")){
		alert("Please include your Phone Number")
		Phone.focus()
		return false
	}
	if (checkInternationalPhone(Phone.value)==false){
		alert("Please include a valid Phone Number")
		Phone.focus()
		return false
	}

  

  return true}