﻿var enabledMenu = false;
var openedMenu = false;	

function slideSwitch(p) {	
	counter++;	
    var active = $('#slide img.active');
	
    if ( active.length == 0 ) active = $('#slide img:last');
    
    var next =  active.next().length ? active.next()
        : $('#slide img:first');		
    active.addClass('last-active');	
	
    next.css({opacity: 0.0})
        .addClass('active')		
        .animate({opacity: 1.0}, 800, function() {
            active.removeClass('active last-active');
			if (counter<3) {
				setTimeout(slideSwitch,2000);
			}else {
				$('#slide').delay(2000).fadeOut("slow");				
				setTimeout(showgallery,2000);
			}
        });
}

function skip_intro(){
	$('#slide').fadeOut("slow");
	showgallery();
}

var counter=0;

function homeSlide() {
	enabledMenu = true;
	counter++;
	
	if(counter>6){
		counter = 1;
		showText(counter);
	}else{
		showText(counter);
	}
	
	
	$('#bottom_line').css("display","none");
	setTimeout(lineMove,3000);
	
    var active = $('#slide img.active');
	
    if ( active.length == 0 ) {
		active = $('#slide img:last');
	}
    
    var next =  active.next().length ? active.next()
        : $('#slide img:first');		
    active.addClass('last-active');	
		
    next.css({opacity: 0.0})
        .addClass('active')		
        .animate({opacity: 1.0}, 800, function() {
            active.removeClass('active last-active');
			setTimeout("homeSlide()",8000);
        });
}

function lineMove(){
	$('#bottom_line').css("display","block");
	$('#bottom_line').css("opacity", 0.75);
	$('#bottom_line').css("marginLeft",-2000);
	$("#bottom_line").stop(true,true).animate({
		marginLeft:0
	    }, 5000, 'easeOutCubic', function() {
		// Animation complete.
	 });
}

function showText(number){
	var z = 0;
	
	if(number == 1){
		z = 6;
	}else{
		z = number-1;
	}
	
	$(".top_desc"+z).fadeOut();
	$(".top_desc"+number).fadeIn();
	
	$(".bottom_desc"+z).fadeOut();
	
	var dd= $('.bottom_desc'+number);
	$(dd).css("opacity", 0.3);
	
	$(".bottom_desc"+number).css("display","block");
	$(".bottom_desc"+number).css("marginLeft",2000);
	$(".bottom_desc"+number).stop(true,true).animate({
		marginLeft:100
	    }, 7500, 'easeOutCubic', function() {
		// Animation complete.
	 });
}

function showgallery(){
	 $(".slide_text").fadeOut();
	 $('#accordion-slider').kwicks({
		 max : 745,		 
		 sticky: true,
		 spacing : 2,
		 defaultKwick : 0,
		 duration: 800,  
		 easing: 'easeOutCubic'
		 });
	enabledMenu = true;
	openedMenu = false;	
	//$("#menu_table").css("marginTop",525);
	$("#menu_portfolio").css("marginTop",550);
}

function showPhilosophy(){	 
	 $('#accordion-slider').kwicks({
		 max : 870,		 
		 sticky: true,
		 spacing : 2,
		 defaultKwick : 0,
		 duration: 800,  
		 easing: 'easeOutCubic'
		 });
}

function showPublications(){	 
	 $('#accordion-slider').kwicks({
		 max : 770,		 
		 sticky: true,
		 spacing : 2,
		 defaultKwick : 0,
		 duration: 800,  
		 easing: 'easeOutCubic'
		 });
}

function mouseposition(){
	var position = $(".main").position();				
	var show = position.top+345;	
	
	
	var IE = document.all?true:false;
	if (!IE) document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = getMouseXY;
	
	var tempY = 0;
	
	function getMouseXY(e) {	
	  if (IE) {	 
		tempY = event.clientY + document.body.scrollTop;
	  } else {  
			tempY = e.pageY
	  }   
		if(tempY >= show){			
			if(openedMenu == false && enabledMenu == true){				
				showmenu();	
				openedMenu = true;
			}		
		}else{
			if(enabledMenu == true){
				hidemenu();
				openedMenu = false;
			}
		}
		return true  
	}
}

var owner = "";

function select_owner(val){
	if(val == "other"){
		$(".inside_divyn").css("display","none");
		owner = $("#other_owner").val();
	}else{
		$(".inside_divyn").css("display","none");	
		owner = val;
		$("#inside_div_"+owner).css("display","block");
	}
}

var project_name = "";

function project_type(type){
	$(".inside_div").css("display","none");	
	project_name = type;
	$("#inside_"+project_name).css("display","block");
	
	switch(type){
		case "urban_planning":
			type = "Urban Planning & Redevelopment";
			break;
		case "residences":
			type = "Residences";
			break;
		case "performing_arts":
			type = "Performing Arts & Museums";
			break;
		case "entertainment":
			type = "Entertainment & Hospitality";
			break;
		case "healt_care":
			type = "Healt Care";
			break;
		case "spas":
			type = "Spas & Aquatic Facilities";
			break;
		case "resorts":
			type = "Resorts & Villas";
			break;
		case "education":
			type = "Education";
			break;
		case "mixed_use_development":
			type = "Mixed Use Development";
			break;
		case "commercial":
			type = "Commercial";
			break;
		case "corporate":
			type = "Corporate";
			break;
		case "sacred_spaces":
			type = "Sacred Spaces";
			break;
	}
	project_name = type;
}

function other_typef(){
	project_name = $("#other_type").val();
	$(".inside_div").css("display","none");	
}

function sendEmail(){
	if($("#first_name").val() == "" || $("#last_name").val() == "" || $("#company").val() == "" || $("#address").val() == "" || $("#city").val() == ""
			|| $("#state").val() == "" || $("#zip_code").val() == "" || $("#home_number").val() == "" || $("#mobile_number").val() == ""
			|| $("#email_address").val() == "" || $("#project_location").val() == "" || $("#time_to_reach").val() == "" || $("#hear").val() == ""
			|| $("#square").val() == "" || $("#budget").val() == "" || $("#project_status").val() == "" || $("#timing").val() == ""
			|| $("#description").val() == ""){																															
		$("#email_msgs").html("Please fill in all fields!").css({'color': '#CCE6C9', 'border': 'none', 'font-family' : 'helvetica', 'font-size' : '13px','padding-left':'15px'}).fadeIn();
		return;
	}
	
	$.ajax({
		type: "POST",
		url: "send_email.php",
		data: "first_name="+$("#first_name").val()+"&last_name="+$("#last_name").val()+"&company="+$("#company").val()+"&address="
				+$("#address").val()+"&city="+$("#city").val()+"&state="+$("#state").val()+"&zip_code="+$("#zip_code").val()
				+"&home_number="+$("#home_number").val()+"&mobile_number="+$("#mobile_number").val()
				+"&email_address="+$("#email_address").val()+"&project_location="+$("#project_location").val()
				+"&time_to_reach="+$("#time_to_reach").val()+"&hear="+$("#hear").val()+"&owner="+owner+"&project_type="+project_name
				+"&other_type="+$("#other_type").val()+"&square="+$("#square").val()+"&budget="+$("#budget").val()
				+"&project_status="+$("#project_status").val()+"&timing="+$("#timing").val()+"&description="+$("#description").val(),
		success: function(msg){			
			$("#email_msgs").html("Message sent !").css({'color': '#CCE6C9', 'border': 'none', 'font-family' : 'helvetica', 'font-size' : '13px','padding-left':'15px'}).fadeIn();
		}
	});
}

function borderChange(div){
	//$("#"+div).css("border","2px solid #879784");	
	//$("#"+div).css("-moz-border-radius","3px");
	//$("#"+div).css("border-radius","3px");
}

function show_project_desc(){
	$(".left_menu_parent_div").css("display","none");
	
	var e=$('#info_background');
	$(e).css("opacity", 0.55);
	
	$("#info_background").fadeIn();	
	$("#inside_info").fadeIn();
	init_dw_Scroll1();	
}

function galery_back(){
	$("#inside_info").fadeOut();
	$("#info_background").fadeOut();
	$(".left_menu_parent_div").css("display","block");
}

function infoMouseOver(page){
	$("#"+page).fadeIn();
}

function infoMouseOut(){
	$(".square_info").fadeOut();
}
