$(document).ready(function(){
		$(".acctitle").each(function(i, el){
			$(el).click(function(){
				var active = $("#accordion").accordion("option","active");
				if(active==i){
					$( "#accordion" ).accordion('activate',(i+1));	
				}
			});
		});
		$("#accordion").accordion({active:4, autoHeight: false});
		
		$(":input[placeholder]").placeholder({overrideSupport:true});
		
		$("#footerhomelink").click(function(){
			$( "#accordion" ).accordion('activate',4);	
		});
		$("#footercompanylink").click(function(){
			$( "#accordion" ).accordion('activate',2);	
		});
		$("#footerpartnerslink").click(function(){
			$( "#accordion" ).accordion('activate',1);	
		});
		$("#footercontactlink").click(function(){
			$( "#accordion" ).accordion('activate',0);	
		});
		$(".footerproductlink").click(function(){
			$( "#accordion" ).accordion('activate',3);	
		});
		
		$("#contact").submit(function(){
			$("#contact").css('visibility', 'hidden');
			$("#contactimg").css('display', 'table-row');
			$("#contactimg").css('visibility', 'visible');
			$.post("ajaxfunctions.php", $("#contact").serialize(), function(data){
				if(data==''){
					var el = $("#contact").parent();
					$("#contact").remove();
					var tmpEl = document.createElement('p');
					$(tmpEl).html('Message sent successfully!');
					$(el).append(tmpEl);
				}else{
					alert(data);
				}
			});
			return false;
		});
		/*
		$("#footerhomelink").click(function(){
			$( "#accordion" ).accordion('activate',4);	
		});
		$("#footerhomelink").click(function(){
			$( "#accordion" ).accordion('activate',4);	
		});
		$("#footerhomelink").click(function(){
			$( "#accordion" ).accordion('activate',4);	
		});
		*/
		$(".contactimg").each(function(i, el){
			$(el).click(function(){
				showContactCard(i);
				/*
				var active = $("#accordion").accordion("option","active");
				if(active==i){
					$( "#accordion" ).accordion('activate',(i+1));	
				}
				*/
			});
		});
});

function hideBrandWindow(){
	//document.getElementById('lightBrand').style.display='none';
	//document.getElementById('fadeBrand').style.display='none';
	$("#fadeBrand").fadeOut("fast");
	$("#lightBrand").fadeOut("fast", function(){
		$("#lightBrand").html('');
	});
	
}
function showBrandWindow(brandID){
	$("#lightBrand").load('ajaxfunctions.php', {'action':'brand','brandID':brandID});
	//document.getElementById('lightBrand').style.display='block';
	//document.getElementById('fadeBrand').style.display='block';
	$("#fadeBrand").fadeIn("slow", function(){$("#fadeBrand").css('filter', 'alpha(opacity=30)');});
	$("#lightBrand").fadeIn("slow");
}
function hideProductWindow(){
	//document.getElementById('lightProduct').style.display='none';
	//document.getElementById('fadeProduct').style.display='none';
	$("#fadeProduct").fadeOut("fast");
	$("#lightProduct").fadeOut("fast", function(){
		$("#lightProduct").html('');
	});
}
function showProductWindow(productID){
	$("#lightProduct").html('<img src="images/ajax-loader.gif" class="loadingimage" />');
	$("#lightProduct").load('ajaxfunctions.php', {'action':'product','productID':productID});
	//document.getElementById('fadeProduct').style.display='block';
	//document.getElementById('lightProduct').style.display='block';
	$("#fadeProduct").fadeIn("slow", function(){$("#fadeProduct").css('filter', 'alpha(opacity=30)');});
	$("#lightProduct").fadeIn("slow");
}
function showContactCard(contactID){
	//document.getElementById('lightBrand').style.display='block';
	//document.getElementById('fadeBrand').style.display='block';
	$("#fadeContact").fadeIn("slow", function(){$("#fadeContact").css('filter', 'alpha(opacity=30)');});
	$("#contactcard"+contactID).fadeIn("slow");
}
function hideContactCard(){
	//document.getElementById('lightProduct').style.display='none';
	//document.getElementById('fadeProduct').style.display='none';
	$("#fadeContact").fadeOut("fast");
	$(".contactcard").fadeOut("fast");
}
