function cleartext(this1){
				if(this1.value==this1.defaultValue){
					this1.value="";
				}
			}

			function cleartext2(this1){
				var fields = jQuery("input[type=text]",this1)
				for(var i=0; i<fields.length; i++){
					cleartext(fields[i]);
				}
			}
var duration=1000; //animation duration


function ajaxmainmenuopen(id,this1,ref){

	if(ref==undefined){
		jQuery("#navsearch .current_page_item").animate({color:"#ffffff"}, duration);
		jQuery("#navsearch .current_page_item").removeClass("current_page_item");
	
		jQuery(this1).addClass("current_page_item");
		jQuery(this1).animate({color:"#349957"},duration);//change the menue
	}else{//dont change its activity
	}

	var temp;
	if(this1==null){
		temp=null
	}else{
		temp=this1.href;
	}
	
		
	
	ajaxmainmenuopencontent(id, temp)
	
}

function ajaxmainmenuopencontent(id, href){

	
	jQuery("#innercontent .maincontent.active").fadeOut(duration/2);
	//jQuery("#innercontent .maincontent.active").fadeTo(duration/2,0.5);
	
	
	
	jQuery("#innercontent .maincontent.active .scontent.active").removeClass("active");
	jQuery("#innercontent .maincontent.active").removeClass("active");//not active any more

	
	

	var start = new Date().getTime();

	
	if(jQuery(".maincontent" + id).length>0){//it exists, so dont load it in

		
		jQuery("#innercontent .maincontent"+id).addClass("active");
		


		var tempint="";
		if(jQuery(".maincontent.active .subhead .subimages.active").length > 0){
			tempint = jQuery(".maincontent.active .subhead .subimages.active").attr("class").match(/subimages[0-9]+/);
			tempint = tempint[0].match(/[0-9]+/);
			
			//var tmpint = parseInt(jQuery(".maincontent.active .subhead .subimages.active").attr("class"));
			jQuery(".maincontent.active .scontent"+tempint).addClass("active");
		}else{//should only be one scontent (hopefully)
			jQuery(".maincontent.active .scontent").addClass("active");
		}
		
		
		//run the page resize scripts
		jQuery(".maincontent.active").css("display", "block");//show block, to calculate size
		jQuery(".scontent.active").parent().animate({height:jQuery(".scontent.active").height()},duration);//height calculation
		jQuery(".maincontent.active").parent().animate({height:jQuery(".maincontent.active").height()},duration);
		jQuery(".maincontent.active").css("display", "none");//hide block, for animation, after size is calculated

		jQuery("#innercontent .maincontent.active").delay(duration/2);
		jQuery("#innercontent .maincontent.active").fadeIn(duration/2);

		ignorehash[ignorehash.length]=jQuery("#innercontent .maincontent.active .scontent.active .namehash").html();
		window.location.hash = jQuery("#innercontent .maincontent.active .scontent.active .namehash").html();
		hash[jQuery("#innercontent .maincontent.active .scontent.active .namehash").html()]=id;//hash to id
		
		
	}else{ //ajax it in
		url=addoption(href,"ajax=1")//mainmenu

		jQuery.ajax({
			  url: url,
			  success: function(data) {

				//create the div for the content to go in
				jQuery("#innercontent").append("<div class='maincontent maincontent"+id+"' style='position:absolute; display:none; min-height:548px;'></div>")

				
				//put the data in the newly created absolute div;

				jQuery("#innercontent .maincontent"+id).addClass("active");

				
				  
				jQuery("#innercontent .maincontent"+id).css("display","block");
			    jQuery("#innercontent .maincontent"+id).html(data);

			    //resize
				var tchildren=jQuery(".scontent.active .postcontent").children();
				jQuery(jQuery(".scontent.active .postcontent").height());

							    
			    
			    jQuery(".scontent.active").parent().height(jQuery(".scontent.active").height()); //reajust height;
			    jQuery(".maincontent.active").parent().animate ({height:jQuery(".maincontent.active").height()}, 120);
			    
			    jQuery("#innercontent .maincontent"+id).css("display","none");

			    
			    
			    //resize the content
			    
			    
				/*
			    hashlock=true;//lock it
				window.location.hash = jQuery("#innercontent .maincontent.active .scontent"+id+" .namehash").html();
				hash[jQuery("#innercontent .maincontent.active .scontent"+id+" .namehash").html()]=id;//hash to id
				setTimeout(function(){hashlock=false,10});//unlock it
				*/
			    
			    var now=new Date().getTime();
			    if(now-start<(duration/2)){//all things are fine, que it up
			    	jQuery(".maincontent.active").delay(duration/2-(now-start));
			    	jQuery(".maincontent.active").fadeIn(duration/2);

			    }else if(now-start<(duration-200)){ //fade in faster
			    	jQuery(".maincontent.active").fadeIn(duration-(now-start));
			    }else{//missed it, fade in normaly
			    	jQuery(".maincontent.active").fadeIn(duration/2);
			    }

				//fixed vertical nav
			    var images = jQuery("#innercontent .maincontent"+id+" .subhead .subimages .title .rotatedtext");
				for(var i=0; i<images.length; i++){
					fixtext(images[i]);
				}
				//eo fixed vertical nav

				

				ignorehash[ignorehash.length]=jQuery("#innercontent .maincontent.active .scontent.active .namehash").html();
				window.location.hash = jQuery("#innercontent .maincontent.active .scontent.active .namehash").html();
				hash[jQuery("#innercontent .maincontent.active .scontent.active .namehash").html()]=id;//hash to id
				//jQuery(window).bind("hashchange", doonhashchange);
			    
			    

			  }
			});
	}
		
}

function fixtext(ele){
	if(jQuery(ele).parent().width()==0){
		setTimeout(function(){fixtext(ele);},100);//if fail try again later
	}else{
		jQuery(ele).height(jQuery(ele).parent().width());
	}
}

var hashlock=false;
window.onhashchange = doonhashchange;


function doonhashchange(){

	
	if(jQuery.inArray(window.location.hash.substring(1) ,ignorehash)!=-1 ||
		(jQuery.inArray(null ,ignorehash)!=-1 && window.location.hash.substring(1)=="") && ignorehash.length>0){
		ignorehash = jQuery.grep(ignorehash, function(value){
				var temp = window.location.hash.substring(1);
				if(window.location.hash.substring(1) == ""){
					temp = null;
				}
		        return value != temp;
		});

		return;
	}


	
	if(jQuery(".scontent.active").parent().parent().parent().attr("class") == jQuery(".scontent"+hash[window.location.hash.substring(1)]).parent().parent().parent().attr("class")
	){
		ajaxsubmenuopen( hash[window.location.hash.substring(1)],null)//dont need href, since it should allready be loaded


	}else if(jQuery(".maincontent" + hash[window.location.hash.substring(1)]+" .subhead:first a .subimages").length!=0 &&
			jQuery(".scontent.active").length!=0 && jQuery(".scontent.active").parent().parent().parent().attr("class") == jQuery(".scontent"+jQuery(".maincontent" + hash[window.location.hash.substring(1)]+" .subhead:first a .subimages").attr("class").match(/[0-9]+/)).parent().parent().parent().attr("class")){
				
		ajaxsubmenuopen( jQuery(".maincontent" + hash[window.location.hash.substring(1)]+" .subhead:first a .subimages").attr("class").match(/[0-9]+/),null)//dont need href, since it should allready be loaded
	}else if(hash[window.location.hash.substring(1)] != undefined){

		ajaxmainmenuopen( jQuery(".scontent"+hash[window.location.hash.substring(1)]).parent().parent().parent().attr("class").match(/[0-9]+/),null)
	}
}

function addoption(url, option){
	if(url.match(/\?/)){
		url=url+"&"+ option;
	}else{
		url=url+"?"+option;
	}
	return url;
}

// the slider
function slidernext(this1){
	if(jQuery('img.active', this1).nextAll("img.slide:first").length==0){
		return;
	}
	
	//slideoff
	jQuery('img.active', this1).animate({left: -jQuery('img.active', this1).width()},1000)

	var tochange =jQuery('img.active', this1).nextAll("img.slide:first");
	jQuery('img.active', this1).removeClass("active");
	
	tochange.addClass("active");
	tochange.css("left", tochange.width() + "px")
	tochange.css("display", "block");
	tochange.animate({left:0},1000);


	var tmphtml;
	if(jQuery(".no a",this1).length==0){
		
		tmphtml=((jQuery(".no",this1)).html());
	}else{
		tmphtml=((jQuery(".no a",this1)).html());
	}
	
	jQuery(".no",this1)[0].innerHTML=(""+(parseInt(tmphtml) + 1));
}

function sliderprev(this1){
	if(jQuery('img.active', this1).prevAll("img.slide:first").length==0){
		return;
	}
	
	//slideoff
	jQuery('img.active', this1).animate({left: jQuery('img.active', this1).width()},1000)

	var tochange =jQuery('img.active', this1).prevAll("img.slide:first");
	jQuery('img.active', this1).removeClass("active");
	
	tochange.addClass("active");
	tochange.css("left", -tochange.width() + "px")
	tochange.css("display", "block");
	tochange.animate({left:0},1000);

	var tmphtml;
	if(jQuery(".no a",this1).length==0){
		
		tmphtml=((jQuery(".no",this1)).html());
	}else{
		tmphtml=((jQuery(".no a",this1)).html());
	}
	
	jQuery(".no",this1)[0].innerHTML=(""+(parseInt(tmphtml) - 1));
}
// eo the alider

//do redirect
if(window.location.hash.substring(1)!=""){
	//redirect to the page
	window.location="http://www.duragarages.com/"+window.location.hash.substring(1);	
}

jQuery(document).ready(function(){jQuery(".scontent.active").parent().height(jQuery(".scontent.active").height());jQuery(".maincontent.active").parent().height(jQuery(".maincontent.active").height());hash[window.location.hash.substring(1)] = initHashid;})

//optima
Cufon.replace('.optima,h1');


