// JavaScript Document
$(document).ready(function() {
next_image=0;

service = new Array("blank.html", "water-damage-repair.html", "fire-damage-repair.html", "mold-damage-repair.html", "asbestos-removal.html", "asbestos-inspection.html", "duct-cleaning.html", "foundation-cracs-repair.html", "mold-removal-chicago.html");
page = new Array("blank.html","","products.html","about.html","contact.html","testimonial.html");
pathname = window.location.pathname;

if(!Array.indexOf){
	Array.prototype.indexOf = function(obj){
		for(var i=0; i<this.length; i++){
			if(this[i]==obj){
				return i;
			}
		}
		return -1;
	}
}

service_url=service.indexOf(pathname.substring(1));
page_url=page.indexOf(pathname.substring(1));

$("#next").click(function(event)
{
	clearInterval(slideShow);
	current_image=image.indexOf($("#pic").attr("src").substring(16));
	if((next_image+1)<image.length)
	{
		next_image=current_image+1;
	}				
	$("#pic").attr("src","/assets/gallery/"+image[next_image]);				
});
$("#prev").click(function(event)
{
	clearInterval(slideShow);
	current_image=image.indexOf($("#pic").attr("src").substring(16));
	if((next_image-1)>=0)
	{
		next_image=current_image-1;
	}				
	$("#pic").attr("src","/assets/gallery/"+image[next_image]);				
});
function slideShow()
{
	current_image=image.indexOf($("#pic").attr("src").substring(16));
	if((next_image+1)<image.length)
	{
		next_image=current_image+1;
	}else
	{
		next_image=0;
	}
	$("#pic").attr("src","/assets/gallery/"+image[next_image]);
}
slideShow = setInterval(slideShow,3000);

$(".service_row").mouseover(function()
{
	$("#"+$(this).attr("id")+" .service_border").addClass("service_hover");
	$("#"+$(this).attr("id")+" .service_border_short").addClass("service_hover");
	$("#"+$(this).attr("id")+" ."+$(this).attr("id")+"_icon").addClass($(this).attr("id")+"_icon_selected");
	$("#"+$(this).attr("id")+" ."+$(this).attr("id")+"_text").addClass($(this).attr("id")+"_text_selected");
});
$(".service_row").mouseout(function()
{
	if(pathname!=$("#"+$(this).attr("id")+" ."+$(this).attr("id")+"_text").attr("href"))
	{
		$("#"+$(this).attr("id")+" .service_border").removeClass("service_hover");
		$("#"+$(this).attr("id")+" .service_border_short").removeClass("service_hover");
		$("#"+$(this).attr("id")+" ."+$(this).attr("id")+"_icon").removeClass($(this).attr("id")+"_icon_selected");
		$("#"+$(this).attr("id")+" ."+$(this).attr("id")+"_icon").addClass($(this).attr("id")+"_icon");
		$("#"+$(this).attr("id")+" ."+$(this).attr("id")+"_text").removeClass($(this).attr("id")+"_text_selected");
		$("#"+$(this).attr("id")+" ."+$(this).attr("id")+"_text").addClass($(this).attr("id")+"_text");
	}				
});
$("#send_form").click(function(event)
{
	$.ajax({
	   type: "POST",
	   url: "send_form.html",
	   data: "&name="+$("#name").val()+"&email="+$("#email").val()+"&phone="+$("#phone").val(),
	   success: function(msg){
		 $(".form").html("<p class=\'quote_text\'>Congratulations!<br/>Your information has been submitted successfully.</p>");
	   }
	 });

});
$('#quote_next').live('click', function() {
	  // Live handler called.
	// Live handler called.
	$(".quote_text").html("Project Information:"); 
	$(".quote_next").html('<a href="#submit" title="Submit Form" id="quote_submit"><img src="/assets/images/send_form_big.gif" alt="Submit Form" /></a><input type="hidden" value="'+$("#quote_name").val()+'" id="quote_name" /><input type="hidden" value="'+$("#quote_value").val()+'" id="quote_value" />');
	$(".quote_group").html('<p class="quote_text_end"><textarea id="quote_msg" class="textarea"></textarea></p>');
});

$("#quote_submit").live('click', function() {
  // Live handler called
	name = $("#quote_name").val();
	contact = $("#quote_value").val();
	msg = $("#quote_msg").val();
	
	// alert(name + '|' + contact + '|' + msg);
	
	$(".textarea").remove();
	$.ajax({
		   type: "POST",
		   url: "send_form.html",
		   data: "&name="+name+"&contact="+contact+"&msg="+msg,
		   success: function(msg){
			 $(".quote_group").html(msg);			 
	   }
	 });
	$(".quote_next").remove();
});

$(".service_row").click(function(event)
{
	window.location=$("#"+$(this).attr("id")+" ."+$(this).attr("id")+"_text").attr("href");
});			
$("#quote_name,#quote_value").click(function(event)
{
	$(this).attr("value","");
	$(this).css("color","black");
});
if(service_url!=-1)
{
	$("#service_0"+service_url+" .service_border").addClass("service_hover");
	$("#service_0"+service_url+" .service_border_short").addClass("service_hover");
	$("#service_0"+service_url+" .service_0"+service_url+"_icon").addClass("service_0"+service_url+"_icon_selected");
	$("#service_0"+service_url+" .service_0"+service_url+"_text").addClass("service_0"+service_url+"_text_selected");
}
if(page_url!=-1)
{	
	$(".nav_0"+page_url+"_a").addClass("nav_0"+page_url+"_a_selected");
}			

});