function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}
	
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];}
}

function MM_validateForm() { //v4.1 adjustment to display the ID tad in the error window
  var i,p,q,nm,nd,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; nd=val.id; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nd+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nd+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nd+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nd+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_validateOfferForm() { //v4.0
  var i,p,q,nm,nd,test,num,min,max,errors='',args=MM_validateOfferForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; nd=val.id; nt=val.title; if (nd == "cName" && val.value == '[+] Name') { val.value = "";}  else { if (nd == "cPhone" && val.value == '[+] Phone') { val.value = "";}} if ((vVal=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=vVal.indexOf('@');
        if (p<1 || p==(vVal.length-1)) errors+='- '+nt+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(vVal);
        if (isNaN(vVal)) errors+='- '+nt+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nt+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nt+' is required.\n'; 
	if ( nd == "cName" && val.value == '') {val.value = "[+] Name";} if (nm == "cPhone" && val.value == '') { val.value = "[+] Phone";} }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
 	document.MM_returnValue = (errors == '');
  	document.oForm.action = "contact-aristotle-development.cfm?sID=2";
}


function MM_validateContactForm() { //v4.0
  var i,p,q,nm,nd,test,num,min,max,errors='',args=MM_validateContactForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; nd=val.id; nt=val.title; if (nd == "cName" && val.value == '[+] Name') { val.value = "";}  else { if (nd == "cPhone" && val.value == '[+] Phone') { val.value = "";}} if ((vVal=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=vVal.indexOf('@');
        if (p<1 || p==(vVal.length-1)) errors+='- '+nt+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(vVal);
        if (isNaN(vVal)) errors+='- '+nt+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nt+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nt+' is required.\n'; 
	if ( nd == "cName" && val.value == '') {val.value = "[+] Name";} if (nm == "cPhone" && val.value == '') { val.value = "[+] Phone";} }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
 	document.MM_returnValue = (errors == '');
  	document.cForm.action = "contact-aristotle-development.cfm?sID=1";
}


var the_timeout;

function setDelay(n) {
	if (n == 0) {
		delay += 1000;
	}
	if (n == 1) {
		if (delay >= 1000) {
			delay -= 1000;
		}
	}
}
var delay = 4000;

function openGallery(a) {
	$('#gallery').fadeIn("slow",function () {
		$('#album'+a).css({display:"none"});
	});
}

thisPage = document.URL.substring(document.URL.lastIndexOf("/")+1 ,document.URL.length);
thisPage = thisPage.substring(0 ,thisPage.lastIndexOf("."));

if(thisPage != "aristotle-development-view-gallery") {
	ddsmoothmenu.init({
		mainmenuid: "mainNav", //menu DIV id
		orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
		classname: 'ddsmoothmenu', //class added to menu's outer DIV
		//customtheme: ["#1c5a80", "#18374a"],
		contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
	})
}

	
$(document).ready(function() {
			
	if(thisPage != "aristotle-development-view-gallery") {
		$.Juitter.start({
			searchType:"fromUser", // needed, you can use "searchWord", "fromUser", "toUser"
			searchObject:"sanna_lee", // needed, you can insert a username here or a word to be searched for, if you wish multiple search, separate the words by comma.
	
			// The values below will overwrite the ones on the Juitter default configuration. 
			// They are optional here.
			// I'm changing here as a example only
			lang:"en", // restricts the search by the given language
			live:"live-60", // the number after "live-" indicates the time in seconds to wait before request the Twitter API for updates.
			placeHolder:"juitterContainer", // Set a place holder DIV which will receive the list of tweets example <div id="juitterContainer"></div>
			loadMSG: "Loading messages...", // Loading message, if you want to show an image, fill it with "image/gif" and go to the next variable to set which image you want to use on 
			imgName: "images/colorbox/loading.gif", // Loading image, to enable it, go to the loadMSG var above and change it to "image/gif"
			total: 1, // number of tweets to be show - max 100
			readMore: "Read it on Twitter", // read more message to be show after the tweet content
			nameUser:"image", // insert "image" to show avatar of "text" to show the name of the user that sent the tweet 
			openExternalLinks:"newWindow", // here you can choose how to open link to external websites, "newWindow" or "sameWindow"
			filter:""  // insert the words you want to hide from the tweets followed by what you want to show instead example: "sex->censured" or "porn->BLOCKED WORD" you can define as many as you want, if you don't want to replace the word, simply remove it, just add the words you want separated like this "porn,sex,fuck"... Be aware that the tweets will still be showed, only the bad words will be removed
		});
	}
			
	if(thisPage == "index" || thisPage == "" || thisPage == "index2") {
		$(".cobContent").equalHeights();
		$(".pNav").tabs("#portfolioDetails > .pt", { effect: 'fade', fadeOutSpeed: "slow", rotate: true }).slideshow({ autoplay: true, interval: 5000 });
		
		var api = $(".pNav").data("tabs");
		
		api.onBeforeClick(function(event, tabIndex) {
			//var tab = this.getIndex()+1;
			var tab = tabIndex;
			if(tab > tCount) { tab = 0; }
			$("#portfolioImage img").fadeOut("fast",function(){
				$("#portfolioImage img").attr("src", "portfolio/album"+pLinks[tab]+"/"+pImages[tab]);
				$("#portfolioImage img").fadeIn("fast");
        	});
			$("#portfolioMoreLink a").attr({href:"aristotle-development-view-gallery.cfm?oID="+pLinks[tab],title:pTitles[tab]});
		});
	}
	
	
	if(thisPage  == "contact-aristotle-development") {
		//initialize();
	}
	
	if(thisPage == "aristotle-development-gallery") {
		$(".gBox").equalHeights();
		
		$('#gallery div').each(function (index, domEle) {
        	//alert(domEle.id);
        	if($(domEle).is(".gAlbum")) {
				if($('#album'+this.id).length > 0) {
					$(domEle).css({'cursor':'pointer'});
				}
				$(domEle).mouseover(function () {
					var thisTop = ((180 - $('#gad' + this.id).height()) - 20) + "px";
					$('#gad' + this.id).stop().animate({top:thisTop},"slow");
				});
				$(domEle).mouseout(function () {
					$('#gad' + this.id).stop().animate({top:"180px"},"slow");					  
				});
				if($('#album'+this.id).length > 0) {
				$(domEle).click(function () {
					$('#album'+this.id).css({'display':'block'});
					$('#gallery').fadeOut("slow");
				});
				}
			}
		 });
		$(".galleryImage").colorbox();
	}
	
	if(thisPage == "aristotle-development-view-gallery") {
		$("#galleryNav li").each(function(index) {
			$(this).hover(function () {
					$(this).fadeTo('fast',1);
				},function () {
					if($(this).hasClass("currentNav")) {
						$(this).fadeTo('fast',1);
					} else {
						$(this).fadeTo('fast',0.5);
					}
				}).fadeTo(0,0.5);
		});
		
		$('#galleryNav li').click(function () {
			var image = $(this).find('img').attr("src");
			image = image.replace("-thumb","");
			$('.backImage img').attr({src: image});
			$('.backImage').fadeTo('fast',0);
			$("#galleryNav li").each(function(index) {
				if($(this).hasClass("currentNav")) { $(this).fadeTo('fast',0.5).removeClass("currentNav"); }
			});
			$(this).addClass("currentNav");
			$('.frontImage').fadeOut('slow',function () {
				$('.backImage').fadeIn('slow',function () { $('.frontImage img').attr({src: image}); $('.frontImage').fadeTo('fast',1) })	
			})
			
			$("#galleryNav li").each(function(index) {
				if($(this).hasClass('currentNav')) {
					$(this).fadeTo('fast',1);
				}
			});
		});
		
		$("#galleryNav li").each(function(index) {
				if($(this).hasClass('currentNav')) {
					$(this).fadeTo('fast',1);
				}
		});
	}
	
	
	if(thisPage == "aristotle-development-case-studies") {
		$(".galleryImage").colorbox();
		$(".caseBoxNav").tabs(".caseBoxPanels > .caseBox", {
	
			// enable "cross-fading" effect
			effect: 'fade',
			fadeOutSpeed: "slow",
		
			// start from the beginning after the last tab
			rotate: true
		
		// use the slideshow plugin. It accepts its own configuration
		}).slideshow({clickable: false});
		
		$(".thumbsNav").tabs(".thumbs > .thumb", {
	
			// enable "cross-fading" effect
			effect: 'fade',
			fadeOutSpeed: "slow",
		
			// start from the beginning after the last tab
			rotate: true
		
		// use the slideshow plugin. It accepts its own configuration
		}).slideshow({clickable: false});
	}
	

	
	//$(".imageBox").colorbox();
	
	$(".showAlbum").colorbox({iframe:true, innerWidth:900, innerHeight:620});
	//$(".showLinkSm").colorbox({iframe:true, innerWidth:600, innerHeight:500});
	//$(".showLinkLg").colorbox({iframe:true, innerWidth:900, innerHeight:700});
	
	
	if(thisPage != "index" || thisPage != "" || thisPage != "aristotle-development-view-gallery") {
		$(".boContent").equalHeights();
		$(".newsletterBox").colorbox({iframe:true, innerWidth:400, innerHeight:300});
	}
	
	if(thisPage != "aristotle-development-view-gallery") {
		$(".fcobContent").equalHeights(70,340);
	}
	
});
