$(document).ready(function(){
	$('#textLogo').click(function(){
		window.open('http://www.irondogmedia.com/index.php','_self');
	});	
	
	
	$('.nav').hover(function(){
		$(this).addClass("navHilite");},function(){$(this).removeClass("navHilite");
	});
	
	$('#requestQuote').click(function(){
		window.open('http://www.irondogmedia.com/projectQuote.php','_self');
	});	
	
	$('#quoteRequestBubble').click(function(){
		window.open('http://www.irondogmedia.com/projectQuote.php','_self');
	});	
	
	$('.thumbPic').click(function(){
		var x = $(this).attr('src');
		var begin = x.indexOf('/')+1;
		var end = x.lastIndexOf('/');
		var proj = x.substring(begin,end);
		var fileName = 'projDetail.php';
		proj += fileName; 
		window.open(proj,'_self');
	});
	
	$('#previousProject').click(function(){ 
		var d = $(this).attr('class');
		var URL = document.URL;
		var newPage = $(this).load("scripts/forwardBack.php", { shiftPage : d , page : URL }, 
			function(data){
				data = 'projectDetail.php?pID=' + data;
				window.open(data,'_self');
			});
	});

	
	$('#nextProject').click(function(){
		var d = $(this).attr('class');
		var URL = document.URL;
		var newPage = $(this).load("scripts/forwardBack.php", { shiftPage : d , page : URL }, 
			function(data){
				data = 'projectDetail.php?pID=' + data;
				window.open(data,'_self');
			});
	});
	
	
	jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
    phone_number = phone_number.replace(/\s+/g, ""); 
	return this.optional(element) || phone_number.length > 9 &&
		phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/); }, "Please specify a valid phone number");

	$("#projectQuote").validate({
  rules: {
    Phone: {
      required: true,
      phoneUS: true
		},
	Numbers: {
		required: true,
		digits: true
		}
  		}
    });

		$("#contactUs").validate({
				rules: {
					phone: {
						required: true, 
						phoneUS: true
					}
				}
			});
			

		$.fx.speeds._default = 250;

		$(".opener").attr("id", function(arr){ 
				return "link" + arr; // assigns an id to all opener class elements based on their position on the page
					}); 
		
		$(".dialogBox").attr("id", function(arr){
				return "box" + arr;	// assigns an id to all dialog box class elements based on ther position on the page
					});
		$(".dialogBox").hide(); // hides dialog boxes for later display when opener class elements are clicked.
					
		$('.opener').click(function(){
			var linkID = $(this).attr("id");
			var linkNo = linkID.slice(linkID.length - 1);
			$('#box' + linkNo).toggle();
		});
		
		$('.accordion_header').addClass('exact_width'); 
		var headerWidth = $('#Discovery').innerWidth(); 
		$('.exact_width').css('width', headerWidth + 10);
		
		//alert (headerWidth);
	
		$('#photoDisplay a').lightBox();
		
		var headerHeight = $('#photoDisplay h1').prop('clientHeight');
		var ieHeight = $('#photoDisplay h1').prop('offsetHeight');
		
		if (headerHeight > 24 || ieHeight > 29){
			$('#photoDisplay h1').addClass('kickUP');
		}
		
			//$('photoDisplay h1').addClass("kickUP"); 
		
		/*
var 2rowHeight = ('#secondRow').prop('clientHeight');
		if (2rowHeight > 113){
			var heightAjust = 2rowHeight - 113;
			$('#secondRow img')
		}
*/
	
});

