// JavaScript Document
ddaccordion.init({
	headerclass: "expandable", //Shared CSS class name of headers group that are expandable
	contentclass: "categoryitems", //Shared CSS class name of contents group
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", "active"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	//togglehtml: ["prefix", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "normal", //speed of animation: "fast", "normal", or "slow"
	onopenclose:function(header, index, state, isuseractivated){/*$(header).css("margin","1px 0");*/}
	});
$(document).ready(function () {
	 // Tab control
	 //$("#top-nav-inner div:not(.loading)").hide();
	 $("#top-nav-inner").tabs({
	    show: function(event, ui){/*$(ui.panel).show();*/}
	    //event: 'mouseover'
	 });
	 $(".sidebar").tabs({
		  selected:0
	    });
	 $("#top-nav-inner div:not(.loading)").show();
	 $("#top-nav-inner div.loading").hide();
	 /*
	$(".top-icons a, .sb-list a, #expand_left a, #expand_right a").tooltip({ 
	    track: false,
	    delay: 0,
	    showURL: false, 
	    showBody: " : ",
	    fade: 250 
	});
	 */
	
	// Footer control
	$(".inner .foot-btn").click(function(){
	    element = "#"+$(this).attr("rel");
	    anotherEle = (element == "#expand_left")? "#expand_right":"#expand_left";
	    
	    $(element).toggle();
	    if($(anotherEle).is(":hidden")){
		  $(element).parent(".expand").toggle();
	    }else{
		  $(anotherEle).hide();
	    }
	    return false;
	 });
	 // Hover tab
	 //$("select").hover(function(){ $(this).hide();},function(){});
	 //$("select[name='a']").hover(function(){ $(this).click();},function(){});
	 
	 $("form .cleardefault").each(function(){
	    $(this).focus(clearDefaultText);
	    $(this).blur(replaceDefaultText);
	    
	    /* Save the current value */
	      if (this.value != '') {
		  this.defaultText = this.value;
		  }
	    });
	 
	 $("form .clearbackground").each(function(){
	    
	    var f = function(){
			this.style.background = '#FFFFFF';
		  };
	    var b = function(){
		  if (this.value == '') {
			   this.style.background = '#ffffff url(images/search-twitter-bg.gif) left no-repeat';
			}
		  };
	    //$(this).focus(clearDefaultText);
	    //$(this).blur(replaceDefaultText);
	    
	    this.onfocus = f;
	    this.onblur = b;
	    
	    /* Save the current value */
	      if (this.value != '') {
		  this.defaultText = this.value;
		  }
	    });
});

function clearDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == target.defaultText) {
        target.value = '';
    }
}

function replaceDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == '' && target.defaultText) {
        target.value = target.defaultText;
    }
}
