var rv = -1;
if (navigator.appName == 'Microsoft Internet Explorer') {
	var ua = navigator.userAgent;
	var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
	if (re.exec(ua) != null)
	rv = parseFloat( RegExp.$1 );
}

var currentFrameinsons = 1;

function updatePiece(){
	switch(currentFrameinsons) {
		case 1:
			frame2();
			currentFrameinsons = 2;
			break;
		case 2:
			frame3();
			currentFrameinsons = 3;
			break;
		case 3:
			frame4();
			currentFrameinsons = 4;
			break;
		case 4:
			frame5();
			currentFrameinsons = 5;
			break;
		case 5:
			frame6();
			currentFrameinsons = 6;
			break;
		case 6:
			frame7();
			currentFrameinsons = 7;
			break;
		case 7:
			frame8();
			currentFrameinsons = 8;
			break;
		case 8:
			frame9();
			currentFrameinsons = 9;
			break;
		case 9:
			frame10();
			currentFrameinsons = 10;
			break;
		case 10:
			frame1();
			currentFrameinsons = 1;
			break;
	}
}

setInterval( "updatePiece()", 10000 );

function killEmAll() {
	$("#dot1").css("background", "url(http://www.p11.com/dev/images/grey.png)");
	$("#dot2").css("background", "url(http://www.p11.com/dev/images/grey.png)");
	$("#dot3").css("background", "url(http://www.p11.com/dev/images/grey.png)");
	$("#dot4").css("background", "url(http://www.p11.com/dev/images/grey.png)");
	$("#dot5").css("background", "url(http://www.p11.com/dev/images/grey.png)");
	$("#dot6").css("background", "url(http://www.p11.com/dev/images/grey.png)");
	$("#dot7").css("background", "url(http://www.p11.com/dev/images/grey.png)");
	$("#dot8").css("background", "url(http://www.p11.com/dev/images/grey.png)");
	$("#dot9").css("background", "url(http://www.p11.com/dev/images/grey.png)");
	$("#dot10").css("background", "url(http://www.p11.com/dev/images/grey.png)");
}

function frame1(){
	if (rv != -1) {
		killEmAll();
		$("#dot1").css("background", "url(http://www.p11.com/dev/images/white.png)");
		$("#projectTitle").html('Studio Exterior');
		$('html, body').animate({scrollTop: $("#bg_1").offset().top}, 2000);
		currentFrameinsons = 1;
	} else {
		$('html, body').animate({scrollTop: $("#bg_1").offset().top}, 2000);
	}
}

function framelight1() {
	killEmAll();
	$("#dot1").css("background", "url(http://www.p11.com/dev/images/white.png)");
	$("#projectTitle").html('Studio Exterior');
	currentFrameinsons = 1;
}

function frame2(){
	if (rv != -1) {
		killEmAll();
		$("#dot2").css("background", "url(http://www.p11.com/dev/images/white.png)");
		$("#projectTitle").html('Calypso Brochure and Stationery');
		$('html, body').animate({scrollTop: $("#bg_2").offset().top}, 2000);
		currentFrameinsons = 2;
	} else {
		$('html, body').animate({scrollTop: $("#bg_2").offset().top}, 2000);
	}
}

function framelight2() {
	killEmAll();
	$("#dot2").css("background", "url(http://www.p11.com/dev/images/white.png)");
	$("#projectTitle").html('Calypso Brochure and Stationery');
	currentFrameinsons = 2;
}

function frame3(){
	if (rv != -1) {
		killEmAll();
		$("#dot3").css("background", "url(http://www.p11.com/dev/images/white.png)");
		$("#projectTitle").html('Park La Brea Apartments Ad Campaign');
		$('html, body').animate({scrollTop: $("#bg_3").offset().top}, 2000);
		currentFrameinsons = 3;
	} else {
		$('html, body').animate({scrollTop: $("#bg_3").offset().top}, 2000);
	}
}

function framelight3() {
	killEmAll();
	$("#dot3").css("background", "url(http://www.p11.com/dev/images/white.png)");
	$("#projectTitle").html('Park La Brea Apartments Ad Campaign');
	currentFrameinsons = 3;
}

function frame4(){
	if (rv != -1) {
		killEmAll();
		$("#dot4").css("background", "url(http://www.p11.com/dev/images/white.png)");
		$("#projectTitle").html('Anaheim Ducks Casino Night Invitation');
		$('html, body').animate({scrollTop: $("#bg_4").offset().top}, 2000);
		currentFrameinsons = 4;
	} else {
		$('html, body').animate({scrollTop: $("#bg_4").offset().top}, 2000);
	}
}

function framelight4() {
	killEmAll();
	$("#dot4").css("background", "url(http://www.p11.com/dev/images/white.png)");
	$("#projectTitle").html('Anaheim Ducks Casino Night Invitation');
	currentFrameinsons = 4;
}

function frame5(){
	if (rv != -1) {
		killEmAll();
		$("#dot5").css("background", "url(http://www.p11.com/dev/images/white.png)");
		$("#projectTitle").html('Pacific Park Special Events Promotion');
		$('html, body').animate({scrollTop: $("#bg_5").offset().top}, 2000);
		currentFrameinsons = 5;
	} else {
		$('html, body').animate({scrollTop: $("#bg_5").offset().top}, 2000);
	}
}

function framelight5() {
	killEmAll();
	$("#dot5").css("background", "url(http://www.p11.com/dev/images/white.png)");
	$("#projectTitle").html('Pacific Park Special Events Promotion');
	currentFrameinsons = 5;
}

function frame6(){
	if (rv != -1) {
		killEmAll();
		$("#dot6").css("background", "url(http://www.p11.com/dev/images/white.png)");
		$("#projectTitle").html('Studio Interior Center Stage');
		$('html, body').animate({scrollTop: $("#bg_6").offset().top}, 2000);
		currentFrameinsons = 6;
	} else {
		$('html, body').animate({scrollTop: $("#bg_6").offset().top}, 2000);
	}
}

function framelight6() {
	killEmAll();
	$("#dot6").css("background", "url(http://www.p11.com/dev/images/white.png)");
	$("#projectTitle").html('Studio Interior Center Stage');
	currentFrameinsons = 6;
}

function frame7(){
	if (rv != -1) {
		killEmAll();
		$("#dot7").css("background", "url(http://www.p11.com/dev/images/white.png)");
		$("#projectTitle").html('Lyon Communities Website');
		$('html, body').animate({scrollTop: $("#bg_7").offset().top}, 2000);
		currentFrameinsons = 7;
	} else {
		$('html, body').animate({scrollTop: $("#bg_7").offset().top}, 2000);
	}
}

function framelight7() {
	killEmAll();
	$("#dot7").css("background", "url(http://www.p11.com/dev/images/white.png)");
	$("#projectTitle").html('Lyon Communities Website');
	currentFrameinsons = 7;
}

function frame8(){
	if (rv != -1) {
		killEmAll();
		$("#dot8").css("background", "url(http://www.p11.com/dev/images/white.png)");
		$("#projectTitle").html('The Lofts at Park Crest Brochure and Stationery');
		$('html, body').animate({scrollTop: $("#bg_8").offset().top}, 2000);
		currentFrameinsons = 8;
	} else {
		$('html, body').animate({scrollTop: $("#bg_8").offset().top}, 2000);
	}
}

function framelight8() {
	killEmAll();
	$("#dot8").css("background", "url(http://www.p11.com/dev/images/white.png)");
	$("#projectTitle").html('The Lofts at Park Crest Brochure and Stationery');
	currentFrameinsons = 8;
}

function frame9(){
	if (rv != -1) {
		killEmAll();
		$("#dot9").css("background", "url(http://www.p11.com/dev/images/white.png)");
		$("#projectTitle").html('Building Industry Association Trade Show Graphics');
		$('html, body').animate({scrollTop: $("#bg_9").offset().top}, 2000);
		currentFrameinsons = 9;
	} else {
		$('html, body').animate({scrollTop: $("#bg_9").offset().top}, 2000);
	}
}

function framelight9() {
	killEmAll();
	$("#dot9").css("background", "url(http://www.p11.com/dev/images/white.png)");
	$("#projectTitle").html('Building Industry Association Trade Show Graphics');
	currentFrameinsons = 9;
}


function frame10(){
	if (rv != -1) {
		killEmAll();
		$("#dot10").css("background", "url(http://www.p11.com/dev/images/white.png)");
		$("#projectTitle").html('1600 Vine Billboard');
		$('html, body').animate({scrollTop: $("#bg_10").offset().top}, 2000);
		currentFrameinsons = 10;
	} else {
		$('html, body').animate({scrollTop: $("#bg_10").offset().top}, 2000);
	}
}

function framelight10() {
	killEmAll();
	$("#dot10").css("background", "url(http://www.p11.com/dev/images/white.png)");
	$("#projectTitle").html('1600 Vine Billboard');
	currentFrameinsons = 10;
}

$(document).scroll(function(){

	if ($(document).scrollTop() < 1024) {
		framelight1();
	}
	
	if ($(document).scrollTop() > 1024-50) {
		framelight2();
	}
	
	if ($(document).scrollTop() > (1024*2)-50) {
		framelight3();
	}
	
	if ($(document).scrollTop() > (1024*3)-50) {
		framelight4();
	}
	
	if ($(document).scrollTop() > (1024*4)-50) {
		framelight5();
	}
	
	if ($(document).scrollTop() > (1024*5)-50) {
		framelight6();
	}
	
	if ($(document).scrollTop() > (1024*6)-50) {
		framelight7();
	}
	
	if ($(document).scrollTop() > (1024*7)-50) {
		framelight8();
	}
	
	if ($(document).scrollTop() > (1024*8)-50) {
		framelight9();
	}
	
	if ($(document).scrollTop() > (1024*9)-50) {
		framelight10();
	}

});

$(document).ready(function(){
		
		framelight1();
		
		jQuery.event.add(window, "load", resizeFrame);
		jQuery.event.add(window, "resize", resizeFrame);

		function resizeFrame() 
		{
			var h = $(window).height();
			var w = $(window).width();

			if (h < 1024) {
				
				$("#bg_1").css("height", 1024);
				$("#bg_2").css("height", 1024);
				$("#bg_3").css("height", 1024);
				$("#bg_4").css("height", 1024);
				$("#bg_5").css("height", 1024);
				$("#bg_6").css("height", 1024);
				$("#bg_7").css("height", 1024);
				$("#bg_8").css("height", 1024);
				$("#bg_9").css("height", 1024);
				$("#bg_10").css("height", 1024);
	
			}
			
			else {
			
				$("#bg_1").css("height", h);
				$("#bg_2").css("height", h);
				$("#bg_3").css("height", h);
				$("#bg_4").css("height", h);
				$("#bg_5").css("height", h);
				$("#bg_6").css("height", h);
				$("#bg_7").css("height", h);
				$("#bg_8").css("height", h);
				$("#bg_9").css("height", h);
				$("#bg_10").css("height", h);
	
			}

			if (w < 940) {
				
				$(".bg_block").css("width", 940);
			
			} 
			
			else {
			
			$(".bg_block").css("width", w); 
			
			}

		$(".bg_block").css("background-position");

	}
});

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_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_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];}
}
