Adroit = {
	root : null,
	
	lastXHR : null,
	
	initialize : function() {
        //this.attachXHRLoading('.ajax-link');
		this.setupRollovers();
		this.addNavigationStyle();
		this.setupFormStyles();
		this.setupPortfolio();
	},
	
	submitInquiry: function(e) {
        this.stopEvent(e);
        var url = $('#sendInquiry-form').attr('action');
        var params = $('#sendInquiry-form').serializeArray();
        $('#TB_ajaxContent').load(url+'123', params, function() {
        
        });
	},
	
	attachXHRLoading : function(query) {
	   $(query).click(function(e) {
			Adroit.stopEvent(e);
			var link = $(this).attr('href');
			if(Adroit.lastXHR === null || Adroit.lastXHR !== link) {
				Adroit.lastXHR = link;
				$('#content').fadeOut('slow', function() {
                    $('#content .ajax-link').unbind('click');
					$('#content').load(link, function() {
                        $('#content').fadeIn('slow', function() {
                            Adroit.setupFormStyles();
                            tb_init('a.thickbox, area.thickbox, input.thickbox');
                            Adroit.attachXHRLoading('#content .ajax-link');
                        });
                    });
				});
				Adroit.loadFooter(link);
			}
		});
	},
	
	loadFooter : function(link) {
	   var footer = link.split('/');
	   $('#footer').fadeOut('slow', function() {
	       $('#footer-quote').load(Adroit.root+'footer/'+footer[1], function() {
	           $('#footer').fadeIn('slow');
	       });
	   });
	},
	
	setupRollovers : function() {
		$('.rollover').hover(function() {
			var currentImg = $(this).attr('src');
			$(this).attr('src', $(this).attr('hover'));
			$(this).attr('hover', currentImg);
		},
		function() {
			var currentImg = $(this).attr('src');
			$(this).attr('src', $(this).attr('hover'));
			$(this).attr('hover', currentImg);
		});
	},
	
	addNavigationStyle : function() {
	   $('.nav-link').click(function() {
	       $('.nav-link').each(function() {
                $(this).removeClass('selected');
                var label = $(this).html();
                label = label.replace('{', '');
                label = label.replace('}', '');
                $(this).html(label);
            });
            $(this).addClass('selected').html('{ '+$(this).html()+' }');
	   });
	},
	
	setupFormStyles : function() {
	   $("input:text, input:password, textarea").focus(function() {
            $(this).attr({ className: "textbox-focus"});
        }).blur(function() {
            $(this).attr({ className: "textbox"});
        });
	},
	
	stopEvent : function(e) {
	    if(e.preventDefault !== undefined) {
	        e.preventDefault();
	    }
	    if(e.stopPropagation !== undefined) {
	        e.stopPropagation();
	    }
	    e.returnValue = false;
	},
	
	setupPortfolio : function(e) {
	   $('.photo').click(function() {
	       $('#select-larger').hide();
	       var photo = $(this);
	       if(photo.attr('largeImage') !== $('#main-image').attr('src')) {
               $('#main-image').fadeOut(function() {
                   $('#image-loading').show();
                   $('#main-image-link').attr('href', photo.attr('largeImage'));
                   $(this).load(function() {
                       if($(this).width() > 295) {
                          $('#main-image').width(295);
                          $('#main-image').css('height', 'auto');
                       }
                       if($(this).height() > 280) {
                          $('#main-image').height(280); 
                          $('#main-image').css('width', 'auto');
                       }
                       $('#image-loading').hide();
                       $(this).fadeIn();
                    }).attr('src', photo.attr('largeImage'));
               });
            }
	   });
	}
	
}
$(function() {
    Adroit.initialize.call(Adroit);
});




// zoOom 1.0
// (c) 2002 Premshree Pillai
// http://www.qiksearch.com
// premshree@hotmail.com
// Loaction of this script :
// http://www.qiksearch.com/javascripts/zooom10.htm
// Visit http://www.qiksearch.com/javascripts.htm for more FREE scripts


// Configure zoOom

//-----------------------------------------------------------------
var img_path="/images/designers-image.jpg"; // The Image Path                     |
var top_pos=130;          // Image position from top              |
var left_pos=162;         // Image position from left             |
var max_width=900;        // Max allowable width                  |
var min_width=10;         // Min allowable width                  |
var time_length=1;        // Zoom delay in milliseconds           |
var stepx=3;               // Pixels by which image should zoomm   |
//-----------------------------------------------------------------



img_act_width=419;
img_act_height=280;
var original_time=time_length;



function zoom_in()
{
 if(document.getElementById("zz").width==0)
  {
   document.getElementById("zz").border=0;
  }
 if(document.getElementById("zz").width!=0)
  {
   if(document.getElementById("zz").width<max_width)
   {
    document.getElementById("zz").width=document.getElementById("zz").width+stepx;
    document.getElementById("zz").height=Math.round(document.getElementById("zz").width*((img_act_height)/(img_act_width)));
    //alert(document.getElementById("zz").width);
    setTimeout("zoom_in()",time_length);
   }
   else
   {
   window.location = "http://www.stilesfischer.com/designers/brittany";
   }
  }  
} 


function zoom_in_nathan()
{
 if(document.getElementById("zz").width==0)
  {
   document.getElementById("zz").border=0;
  }
 if(document.getElementById("zz").width!=0)
  {
   if(document.getElementById("zz").width<max_width)
   {
    document.getElementById("zz").width+=stepx;
   document.getElementById("zz").height=Math.round(document.getElementById("zz").width*((img_act_height)/(img_act_width)));
    
    var x=document.getElementById("t2").style.left;
    x=x.substr(0,x.length-2);
    document.getElementById("t2").style.right=document.getElementById("zz").width-img_act_width;
    setTimeout("zoom_in_nathan()",time_length);
   }
   else
   {
   window.location = "http://www.stilesfischer.com/designers/nathan";
   }
  }  
} 



function resume_zoom()
{
 time_length=original_time;
}

function pause_zoom()
{
 time_length=10000000000;
}

function set_original()
{
 document.getElementById("zz").width=img_act_width;
 document.getElementById("zz").height=img_act_height;
}

function slider()
{
	
	
	//document.getElementById("a1").value=document.getElementById("sliderid").style.right;
   // var s = 'X=' + window.event.clientX +  ' Y=' + window.event.clientY ;
    //document.getElementById('oid').innerText = s;
   
	
	move();

}  

	
	

	var time_length=1;        // Zoom delay in milliseconds           |
    var step=0.05;
    var count=0;  
    var movement;
	//document.getElementById("sliderid").style.right=10+ 'px';
	
  
	
function move()
{ 
	
    var x=document.getElementById("sliderid").style.right;
    
    var y=x.substr(0,x.length-2);
    
   
  
   
    if(xx!=null){
    if( ( xx> 70) && ( xx< 360)){
    	
    	//step=Math.round((2/320)*(390-xx)) ;
    	count=count+step;	
    	//document.getElementById("a1").value=step;
    	movement="L";
    	
    } if(( xx> 460) && ( xx< 734)){
    
    //step=Math.round((2/320)*(734-xx)) ;
    	count=count-step;	
    	//document.getElementById("a1").value=step;
    	movement="R";
    
    }
    
    if(( xx> 360) && ( xx< 460)){
    
       return;
    
    }
    
    
    }else{
    	step=1;
    }
    	
  
  
    if(movement=="R" && y<=0 ){
    	return;
    }
    
    
    if(movement=="L" && y>=2540){
    	return;
    }
    document.getElementById("sliderid").style.right=count+'px';   
    setTimeout("move()",10);
    
    
    
  
    
} 
	
	


var mousex = 0;
var mousey = 0;
var grabx = 0;
var graby = 0;
var orix = 0;
var oriy = 0;
var elex = 0;
var eley = 0;
var algor = 0;

// used to block cascading events

function init()
{
  document.onmousemove = update; // update(event) implied on NS, update(null) implied on IE
  update();
}

function getMouseXY(e) // works on IE6,FF,Moz,Opera7
{ 
  if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)

  if (e)
  { 
    if (e.pageX || e.pageY)
    { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
      mousex = e.pageX;
      mousey = e.pageY;
      algor = '[e.pageX]';
      if (e.clientX || e.clientY) algor += ' [e.clientX] '
    }
    else if (e.clientX || e.clientY)
    { // works on IE6,FF,Moz,Opera7
      mousex = e.clientX + document.body.scrollLeft;
      mousey = e.clientY + document.body.scrollTop;
      algor = '[e.clientX]';
      if (e.pageX || e.pageY) algor += ' [e.pageX] '
    }  
  }
}

function update(e)
{
  getMouseXY(e); // NS is passing (event), while IE is passing (null)
  xx=mousex;
  
}

var count=6;

function getImageName(id){
   
if(id==4) return "bathroom_interior_design_remodel_san_clemente_california_2.jpg";
if(id==21) return "bathroom_remodel_project_orange_county_interior_design_2.jpg";
if(id==30) return "botique_interior_designer_orange_county_2.jpg";
if(id==28) return "california_residential_interior_design_traditional_home_2.jpg";
if(id==5) return "commercial_interior_designer_contemporary_salon_2.jpg";
if(id==26) return "conceptual_interior_design_sketch_living_room_irvine_2.jpg";
if(id==35) return "dining_room_interior_design_orange_county_furniture_and_paint_2.jpg";
if(id==9) return "ecclectic_interior_design_orange_county_2.jpg";
if(id==10) return "hair_salon_interior_designer_los_angeles_entry_2.jpg";
if(id==11) return "hollywood_regency_interior_design_orange_county_california_bathroom_2.jpg";
if(id==12) return "hollywood_regency_style design entry orange county 2.jpg";
if(id==13) return "interior_and_graphic_design_orange_county_2.jpg";
if(id==14) return "interior_design_asian_furniture_and_bookcase_2.jpg";
if(id==15) return "interior_designers_material_board_fabrics_and_furniture_2.jpg";
if(id==16) return "irvine_interior_design_contemporary_family_room_2.jpg";
if(id==17) return "irvine_interior_design_contemporary_fireplace_2.jpg";
if(id==18) return "irvine_interior_design_dining_room_2.jpg";
if(id==19) return "laguna_beach_interior_design_bedroom_2.jpg";
if(id==20) return "laguna_beach_interior_designer_living_room_2.jpg";
if(id==3) return "laguna_niguel_living_room_design_2.jpg";
if(id==22) return "modern_bedroom_orange_county_interior_design_drawing_2.jpg";
if(id==23) return "new_construction_design_project_california_2.jpg";
if(id==24) return "new_construction_home_design_california_2.jpg";
if(id==25) return "newport_beach_interior_design_contemporary_bedroom_2.jpg";
if(id==8) return "newport_beach_interior_design_entry_2.jpg";
if(id==27) return "office_interior_design_space_plan_2.jpg";
if(id==29) return "orange_county_bathroom_remodel_2.jpg";
if(id==6) return "orange_county_residential_home_design_interior_designer_2.jpg";
if(id==2) return "orange_county_residential_interior_designer_living_room_2.jpg";
if(id==31) return "orange_county_window_treatment_design_and_custom_furniture_2.jpg";
if(id==32) return "salon_interior_design_los_angeles_2.jpg";
if(id==33) return "traditional_entry_interior_decorating_drawing_2.jpg";
if(id==34) return "traditional_interior_design_project_orange_county_2.jpg";
if(id==7) return "palm_desert_dining_interior_design_2.jpg";
if(id==1) return "residential_dining_room_remodel_2.jpg";


}


function getLargeImageName(id){
   
if(id==4) return "bathroom_interior_design_remodel_san_clemente_california.jpg";
if(id==21) return "bathroom_remodel_project_orange_county_interior_design.jpg";
if(id==30) return "botique_interior_designer_orange_county.jpg";
if(id==28) return "california_residential_interior_design_traditional_home.jpg";
if(id==5) return "commercial_interior_designer_contemporary_salon.jpg";
if(id==26) return "conceptual_interior_design_sketch_living_room_irvine.jpg";
if(id==35) return "dining_room_interior_design_orange_county_furniture_and_paint.jpg";
if(id==9) return "ecclectic_interior_design_orange_county.jpg";
if(id==10) return "hair_salon_interior_designer_los_angeles_entry.jpg";
if(id==11) return "hollywood_regency_interior_design_orange_county_california_bathroom.jpg";
if(id==12) return "hollywood_regency_style_design_entry_orange_county.jpg";
if(id==13) return "interior_and_graphic_design_orange_county.jpg";
if(id==14) return "interior_design_asian_furniture_and_bookcase.jpg";
if(id==15) return "interior_designers_material_board_fabrics_and_furniture.jpg";
if(id==16) return "irvine_interior_design_contemporary_family_room.jpg";
if(id==17) return "irvine_interior_design_contemporary_fireplace.jpg";
if(id==18) return "irvine_interior_design_dining_room.jpg";
if(id==19) return "laguna_beach_interior_design_bedroom.jpg";
if(id==20) return "laguna_beach_interior_designer_living_room.jpg";
if(id==3) return "laguna_niguel_living_room_design.jpg";
if(id==22) return "modern_bedroom_orange_county_interior_design_drawing.jpg";
if(id==23) return "new_construction_design_project_california.jpg";
if(id==24) return "new_construction_home_design_california.jpg";
if(id==25) return "newport_beach_interior_design_contemporary_bedroom.jpg";
if(id==8) return "newport_beach_interior_design_entry.jpg";
if(id==27) return "office_interior_design_space_plan.jpg";
if(id==29) return "orange_county_bathroom_remodel.jpg";
if(id==6) return "orange_county_residential_home_design_interior_designer.jpg";
if(id==2) return "orange_county_residential_interior_designer_living_room.jpg";
if(id==31) return "orange_county_window_treatment_design_and_custom_furniture.jpg";
if(id==32) return "salon_interior_design_los_angeles.jpg";
if(id==33) return "traditional_entry_interior_decorating_drawing.jpg";
if(id==34) return "traditional_interior_design_project_orange_county.jpg";
if(id==7) return "palm_desert_dining_interior_design.jpg";
if(id==1) return "residential_dining_room_remodel.jpg";

}

	
function next(){
	
if(count==7) { count=6;}	
	
if(count <=30){
	
	
	
document.getElementById("img1").src="/imagesx/thumb/"+getImageName(count+1);
document.getElementById("img2").src="/imagesx/thumb/"+getImageName(count+2);
document.getElementById("img3").src="/imagesx/thumb/"+getImageName(count+3);
document.getElementById("link1").href="/imagesx/large/"+getLargeImageName(count+1);
document.getElementById("link2").href="/imagesx/large/"+getLargeImageName(count+2);
document.getElementById("link3").href="/imagesx/large/"+getLargeImageName(count+3);
document.getElementById("img4").src="/imagesx/thumb/"+getImageName(count+4);
document.getElementById("img5").src="/imagesx/thumb/"+getImageName(count+5);
document.getElementById("img6").src="/imagesx/thumb/"+getImageName(count+6);
document.getElementById("link4").href="/imagesx/large/"+getLargeImageName(count+4);
document.getElementById("link5").href="/imagesx/large/"+getLargeImageName(count+5);
document.getElementById("link6").href="/imagesx/large/"+getLargeImageName(count+6);



if(count+6 >35){

document.getElementById("img6").src="/imagesx/thumb/"+getImageName(1);
document.getElementById("link6").href="/imagesx/large/"+getLargeImageName(1);

count=35;

}else{
	
count=count+6;	
}






}
	
}

function prev(){
	
if(count==35) { count=31;}	
	
if(count >6){	
document.getElementById("img1").src="/imagesx/thumb/"+getImageName(count-6);
document.getElementById("img2").src="/imagesx/thumb/"+getImageName(count-5);
document.getElementById("img3").src="/imagesx/thumb/"+getImageName(count-4);
document.getElementById("img4").src="/imagesx/thumb/"+getImageName(count-3);
document.getElementById("img5").src="/imagesx/thumb/"+getImageName(count-2);
document.getElementById("img6").src="/imagesx/thumb/"+getImageName(count-1);

document.getElementById("link1").href="/imagesx/large/"+getLargeImageName(count-6);
document.getElementById("link2").href="/imagesx/large/"+getLargeImageName(count-5);
document.getElementById("link3").href="/imagesx/large/"+getLargeImageName(count-4);
document.getElementById("link4").href="/imagesx/large/"+getLargeImageName(count-3);
document.getElementById("link5").href="/imagesx/large/"+getLargeImageName(count-2);
document.getElementById("link6").href="/imagesx/large/"+getLargeImageName(count-1);

if((count-6)>7){ 
count=count-6 ;

}else{
 count=7;	
}


}
	
}


