function windowPosition(){
	if($(window).height() < 600){
		$('#mainContainer').css({'top':'0px','margin-top':'0px'});
		$('#navigation').css({'top':'0px','margin-top':'0px'});
		$('#contactInfo').css({'top':'80px','margin-top':'0px'});
		$('#contactInfoBg').css({'top':'-53px','margin-top':'0px'});

	}
	
	$(window).resize(function(){
		if($(window).height() < 600){
			$('#mainContainer').css({'top':'0px','margin-top':'0px'});
			$('#navigation').css({'top':'0px','margin-top':'0px'});
			$('#contactInfo').css({'top':'80px','margin-top':'0px'});
			$('#contactInfoBg').css({'top':'-53px','margin-top':'0px'});
		}
		else{
			$('#mainContainer').css({'top':'50%','margin-top':'-300px'});
			$('#navigation').css({'top':'50%','margin-top':'-300px'});
			$('#contactInfo').css({'top':'50%','margin-top':'-220px'});
			$('#contactInfoBg').css({'top':'50%','margin-top':'-353px'});
		}
	});
}

function shoppingCartFunctions(templateSrc){
	
	thisSrc = templateSrc + '/images/products-place-order.jpg';
	
	$("#shoppingCart>#Table_01>tbody>tr>td>div>div.shopping_cart>table>tbody>tr>td>form").attr({action:"shopping-cart-submit"});
	$("#shoppingCart>#Table_01>tbody>tr>td>div>div.shopping_cart>table>tbody>tr>td>form>.wp_cart_checkout_button").attr({src:thisSrc});
}

function productsFunctions(templateSrc){
	/* operations for products page */
	$('#productsNav>ul>li').mouseover(function(){
		$(this).addClass('selected');
	}).mouseout(function(){
		$(this).removeClass('selected');
	});
	
	$('#productList>.wrapper>.product>img').click(function(){
		thisId = $(this).parent().attr("id");
		frameInfo = '<div class="popup"><img src="' + templateSrc + '/images/popup-x.gif" class="close" /><iframe src="../?p=' + thisId + '" border="0" style="border:none;margin:51px 0 0 0px;" scrolling="no" width="414" height="500"></iframe></div>';
		
		$('#overlay2').append(frameInfo);
		
		$('#overlay2').fadeIn();
		
		$('.close').click(function(){
			$('#overlay2').fadeOut();
			$('.popup:visible').fadeOut();
		});
		
	});
	
	$('#productList>.wrapper>.product>p>img').click(function(){
		thisId = $(this).parent().parent().attr("id");
		frameInfo = '<div class="popup"><img src="' + templateSrc + '/images/popup-x.gif" class="close" /><iframe src="../?p=' + thisId + '" border="0" style="border:none;margin:51px 0 0 0px;" scrolling="no" width="414" height="500"></iframe></div>';
		
		$('#overlay2').append(frameInfo);
		
		$('#overlay2').fadeIn();
		
		$('.close').click(function(){
			$('#overlay2').fadeOut();
			$('.popup:visible').fadeOut();
		});
		
	});
}


function removeOverlay(){
	$('#overlay').click(function(){
		$(this).fadeOut();
		$('#overlay').empty();
	});
	
	$('#overlay2').click(function(){
		$(this).fadeOut();
		$('#overlay2').empty();
	});

}

function aboutAnimation(){
	/* about page animation */
	$('#aboutText').fadeIn(3000);
	
	$('#aboutImage1').animate({
		"right":"438px"
	},2000);
	
	$('#aboutImage2').animate({
		"left":"291px"
		},2200);
		
	$('#aboutImage3').animate({
		"right":"478px"
		},2200);
}

function homeAnimation(){
/* homepage animation */
	$('#homeCenterImage').each(function(){
		$(function() {
			setInterval( "slideSwitch()", 3000 );
		});
	});
}

function blogAnimation(){
	/* blog and press/news animation */
	$('#blogContainer').fadeIn(2500);
}

function contactAnimation(){
	/* animation for contact page */
	$('#contactText').fadeIn(2500);
	
	$('#contactImage1').animate({ 
		"left":"290px"
		},2300);
	
	$('#contactImage2').animate({ 
		"right":"24px"
		},2100);
}

function greenAnimation(){
	/* animation for green light page */
	$('#greenLightText').fadeIn(2500);
	
	$('#greenLightImage').animate({ 
		"left":"50%"
		},2300);
	
	$('#greenLightHeadline').animate({ 
		"right":"107px"
		},2100);
}

function productAnimation(){
	/* animation for products page */
	$('#productsNav').animate({ 
		"bottom":"88px"
		},2300);
	
	$('#productsHeadline').animate({ 
		"right":"0"
		},2300);
	
	$('#productsImage').animate({ 
		"top":"105px"
		},2300);
}

function staffAnimation(){
	/* meet the team animations */
	$('#taylor').animate({
		"left":"290px"
		},2100);
	
	$('#rob').animate({
		"left":"407px"
		},2500);
	
	$('#maxwell').animate({ 
		"right":"52px"
		},2000);
	
	//$('#donjenna').animate({
		//"right":"251px"
//		},2000);
		
	 $('#donjenna').animate({ 
		"left":"279px"
		},2400);
		
	$('#karen').animate({
		"right":"91px"
		},2200);
		
	$('#joanne').animate({
		"right":"234px"
		},2100);
		
	$('#charlote').animate({ 
		"left":"405px"
		},2300);
}

function staffRollover(){
	
	$('.staffPic>img').mouseover(function(){				
		person = $(this).parent().attr("id");
		$(".staffProfile:visible").fadeOut(function(){
			switch(person){
				case 'karen':
					person = "#profile29";
					break;
				case 'taylor':
					person = "#profile31";
					break;
				case 'maxwell':
					person = "#profile33";
					break;
				case 'charlote':
					person = "#profile35";
					break;
				case 'donjenna':
					person = "#profile6460";
					break;		
				case 'rob':
					person = "#profile23";
					break;
				case 'joanne':
					person = "#profile41";
					break;
			}
			
			$(person).fadeIn();  	
				
		});
	});
		
}

	
function navRollover(){
	$('#navItems>li>a>img').mouseover(function(){
		var thisSrc = $(this).attr("src");
		thisSrc = thisSrc.replace('.png','_over.png');
		$(this).attr({src:thisSrc});
	}).mouseout(function(){
		thisSrc = $(this).attr("src");
		thisSrc = thisSrc.replace('_over.png','.png');
		$(this).attr({src:thisSrc});
	});;
		
	$('#navItems>li>a.selected').children('img').each(function(){
		var thisSrc = $(this).attr("src");
		thisSrc = thisSrc.replace('.png','_over.png');
		$(this).attr({src:thisSrc});
	});
}




function productScrolling(templateSrc){

	// Set width of Products Div
	productNumber = $('#productList>.wrapper').length;									// Get number of products
	//productScreens = Math.round(productNumber/6);											// Total number of screens by dividing by # of products on a screen
	//productTotal = productNumber > productScreens ? productScreens++ : productScreens;		// If there is an extra product, add one screen
	screenWidth = productNumber * 427;
	
	$('#productList').css({width:screenWidth + "px"});							
	if(productNumber >= 1){
		$('#productsScrollLeft').append('<img src="' + templateSrc + '/images/products-arrow-left.png" />');
		$('#productsScrollRight').append('<img src="' + templateSrc + '/images/products-arrow-right.png" />');
	}
		
	$('#productsScrollRight>img').click(function(){
		curLeft = $('#productList').css("left");
		curLeft = curLeft.replace('px','');
		parseFloat(curLeft);
		negScreenWidth = -screenWidth + 427;
		if(curLeft > negScreenWidth){
			$('#productList').animate({left:"-=427"});
	}});
	
	$('#productsScrollLeft>img').click(function(){
		curLeft = $('#productList').css("left");
		curLeft = curLeft.replace('px','');
		parseFloat(curLeft);
		if(curLeft < 0){
			$('#productList').animate({left:"+=427"});
		}
	});


}


function slideSwitch() {
    var $active = $('#homeCenterImage IMG.active');

    if ( $active.length == 0 ) $active = $('#homeCenterImage IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#homeCenterImage IMG:first');


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function emailLink(templateSrc){
	$('a.emailLink').attr({href:'#eml'});
	$('a.emailLink').click(function(){
			frameInfo = '<div class="popup" id="email" style="width:400px;height:630px;background:none;margin-top:-390px;"><img src="' + templateSrc + '/images/popup-x.gif" class="close" style="position:relative;top:95px;left:165px;" /><iframe src="' + templateSrc + '/email.php" border="0" style="border:none;margin:31px 0 0 40px;" scrolling="no" width="600" height="630"></iframe></div>';
			
			$('#overlay3').append(frameInfo);
			
			$('#overlay3').fadeIn();

			
			$('.close').click(function(){
				$('#overlay3').fadeOut();
				$('.popup:visible').fadeOut();
			});
			
		
		$('#overlay3').click(function(){
			$(this).fadeOut();
			$('#overlay3').empty();
		});
		
	});
	
	$('#emailcrap a').attr({href:'#eml'});
	$('#emailcrap a').click(function(){
			frameInfo = '<div class="popup" id="email" style="width:400px;height:630px;background:none;margin-top:-390px;"><img src="' + templateSrc + '/images/popup-x.gif" class="close" style="position:relative;top:95px;left:165px;" /><iframe src="' + templateSrc + '/email.php" border="0" style="border:none;margin:31px 0 0 40px;" scrolling="no" width="600" height="630"></iframe></div>';
			
			$('#overlay3').append(frameInfo);
			
			$('#overlay3').fadeIn();
			
			
			$('.close').click(function(){
				$('#overlay3').fadeOut();
				$('.popup:visible').fadeOut();
			});
			
		
		$('#overlay3').click(function(){
			$(this).fadeOut();
			$('#overlay3').empty();
		});
		
	});
}
