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 logoScroll = function () {
		var myFx = new Fx.Scroll(window, {
			offset: {
				'y': 710
			},
			duration: 750,
			transition: Fx.Transitions.Quad.easeOut
		}).toTop();
	
	}
	$('logo-portfolio-scroll').addEvent('click', logoScroll);
	$$('a.portfolio-logo').addEvent('click', logoScroll);
	$('nav-logo').addEvent('click', logoScroll);	
	var portfolioLink = $('logo-portfolio-scroll');
	$('logo-portfolio-scroll').addEvent('mouseenter', function(){ portfolioLink.setStyle('top', '-138px'); });
	$('logo-portfolio-scroll').addEvent('mouseleave', function(){ portfolioLink.setStyle('top', '0px'); });	
}


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

var $j = jQuery.noConflict();

var moving = false;

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

	$j("#info-up").css("display","none");
		
	$j("#info-down").mousehold(function(){
		var top = $j("#info-box2").css("top");	
		var display = $j("#info-up").css("display");
		var height = $j('#info-box2').innerHeight();	
		var containerHeight = $j("#info-box1").css("height");
	
		top = top.replace("px","")
		containerHeight = containerHeight.replace("px","")
			
		top = parseInt(top)
		containerHeight = parseInt(containerHeight)
		
		var maxTop = height - containerHeight;
			
		maxTop = maxTop - (maxTop*2);
			
		var nextTop = top - 30;
	
		if (nextTop < maxTop) {			
			nextTop = maxTop;
		}
		
		if (display == "none") {		
			$j("#info-up").css("display","inline");
		}
		
		if (moving == false) {	
			moving = true;
			$j("#info-box2").animate({"top": nextTop}, 600,function(){
				 moving = false;
				 if (nextTop == maxTop) {
					$j("#info-down").css("display","none");
				}				 
			});
		}
	});	
	
	$j("#info-up").mousehold(function(){
		var top = $j("#info-box2").css("top");	
		var display = $j("#info-down").css("display");	
		top = top.replace("px","")	
		top = parseInt(top)
			
		maxTop = 0;
		
		var nextTop = top + 30;
		
		if (nextTop > maxTop) {		
			nextTop = maxTop;	
		}
		
		if (display == "none") {		
			$j("#info-down").css("display","inline");
		}
		
		if ((top < 0) && (moving == false)) {
			moving = true;
			$j("#info-box2").animate({"top": nextTop}, 600,function(){
				 moving = false;
				 if (nextTop == maxTop) {
					$j("#info-up").css("display","none");
				}	
			});
		}
		
	
	});		
	
	
	// Home - Turn on this light and turn off home light
	
	$j("#home").mouseover(function(){
	
		$j("#home > h2 > a").addClass("active");
		
		$j("#logo-design > 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("#logo-design > h2 > a").addClass("active");
	
	});
	
	
	// Logo Design - Turn on this light and turn off home light
	
	$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 - Slide out ul
	
	$j("#logo-design > h2 > a").mouseover(function(){
												   
		$j("#logo-design > ul").stop().animate({height:'94px'},{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:'94px'},{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:'180px'},{queue:false, duration:250, easing: 'easeOutQuad'});
	
	});
	
	// Logo Design Sub Prices Link - Slide out
	
	$j("#logo-design > ul > li > h3 > a.prices").mouseover(function(){
												   
		$j("#logo-design > ul > li > h3 > a.prices").stop().animate({height:'107px'},{queue:false, duration:250, easing: 'easeOutQuad'});
		
		$j("#logo-design > ul").stop().animate({height:'180px'},{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("#logo-design > 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("#logo-design > 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:'94px'},{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:'94px'},{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:'180px'},{queue:false, duration:250, easing: 'easeOutQuad'});
	
	});
	
	// Corporate Identity Design Sub Prices Link - Slide out
	
	$j("#corporate-identity-design > ul > li > h3 > a.prices").mouseover(function(){
												   
		$j("#corporate-identity-design > ul > li > h3 > a.prices").stop().animate({height:'107px'},{queue:false, duration:250, easing: 'easeOutQuad'});
		
		$j("#corporate-identity-design > ul").stop().animate({height:'180px'},{queue:false, duration:250, easing: 'easeOutQuad'});
	
	});
	
	
	// Prices & Packages - Turn on this light and turn off home light
	
	$j("#prices").mouseover(function(){
	
		$j("#prices > h2 > a").addClass("active");
		
		$j("#logo-design > h2 > a").removeClass("active");
	
	});
	
	// Prices & Packages - Turn off this light and turn on home light
	
	$j("#prices").mouseout(function(){
	
		$j("#prices > h2 > a").removeClass("active");
		
		$j("#logo-design > h2 > a").addClass("active");
	
	});
	
	
	// Contact - Turn on this light and turn off home light
	
	$j("#contact").mouseover(function(){
	
		$j("#contact > h2 > a").addClass("active");
		
		$j("#logo-design > 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("#logo-design > h2 > a").addClass("active");
	
	});
	
	
	$j('#nav a.go')
	.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}
  
/* Rollover */

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}