
/* Find offset poistions*/
function findPos(inp){
	obj = document.getElementById(inp);
	var curleft = curtop = 0;
	if (obj.offsetParent) {
	do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
	} while (obj = obj.offsetParent);
	}
    return [curleft,curtop];
}

/* when Body onload event Fire.... */
$(document).ready(function() {
    try{
        if($("#ctl00_DataHolder_txtCompanysearch").attr("tabindex"))
        {
        $("#ctl00_DataHolder_txtCompanysearch").focus();
        }
        else if($("#ctl00_DataHolder_txtTitle").attr("tabindex"))
        {
        $("#ctl00_DataHolder_txtTitle").focus();
        }
        else{
        $("#TXT_Search_1").focus();
        }
        var PositionLeft = Math.ceil((document.body.clientWidth-601)/2)+461;
       	var PositionTop = findPos('TXT_Search_1')[1]+$("#TXT_Search_1").height()+4;
		$("div#Listitems").attr("style","left:"+PositionLeft+"px;top:"+PositionTop+"px");
        $('a[href*="#"]').click(function() {
           if (location.pathname == this.pathname && location.host == this.host) {
             var target = $(this.hash);
             target = target.size() && target || $("[name=" + this.hash.slice(1) +']');
             if (target.size()) {
                 target.ScrollTo(400);
                 return false;
             }
          };
        });
    }
    catch(e){
    }
		$("#dropdown").click(function(){
			 
                $("div.dropdown").slideToggle("slow");
             
		});
		$("li#DPL_Item_0").click(function () { 
      		$("span#lblinustry").text($("li#DPL_Item_0").text());
      		document.getElementById("ctl00_HDN_Combo").value=$("li#DPL_Item_0").text();
      		$("div.dropdown").slideUp("slow");	
     		 document.getElementById("ctl00_RepSearch").focus();
   		 });
		$("li#DPL_Item_1").click(function () { 
      		$("span#lblinustry").text($("li#DPL_Item_1").text());
      		document.getElementById("ctl00_HDN_Combo").value=$("li#DPL_Item_1").text();
      		$("div.dropdown").slideUp("slow");
      		 document.getElementById("ctl00_RepSearch").focus();
   		 });
		$("li#DPL_Item_2").click(function () { 
      		$("span#lblinustry").text($("li#DPL_Item_2").text());
      		document.getElementById("ctl00_HDN_Combo").value=$("li#DPL_Item_2").text();
      		$("div.dropdown").slideUp("slow");
      		 document.getElementById("ctl00_RepSearch").focus();
   		 });
		 $("li#Tab__1").click(function(){
			$("ul#maintabs li a").removeClass("alphabetvisited");
      		$("ul#maintabs li a").addClass("alphalinks");
			$("li#Tab__1 a").addClass("alphabetvisited");
			$("#ctl00_DataHolder_divindustry").css("display","block");
			$("#ctl00_DataHolder_divCompanies").css("display","none");
   		 });
		$("li#Tab__2").click(function(){
			$("ul#maintabs li a").removeClass("alphabetvisited");
      		$("ul#maintabs li a").addClass("alphalinks");
			$("li#Tab__2 a").addClass("alphabetvisited");
			$("#ctl00_DataHolder_divindustry").css("display","none");
			$("#ctl00_DataHolder_divCompanies").css("display","block");
   		 });
});
/* when Body onclick event Fire.... */
$(document.body).mousedown(function () {
    try{
        if($("div.dropdown").css("display")=="block")
        {
            $("div.dropdown").slideUp("slow");
        }
    }
    catch(e){
        //
    }
});
$(document).ready(function() {

    // Auto suggest control intiated;
    var oTextbox = new AutoSuggestControl(document.getElementById("TXT_Search_1"), new StateSuggestions());        


	function filterPath(string) {
		return string.replace(/^\//,'').replace(/(index|default).[a-zA-Z]{3,4}$/,'').replace(/\/$/,'');
	}
	var locationPath = filterPath(location.pathname);
	$('a[href*=#]').each(function() {
		var thisPath = filterPath(this.pathname) || locationPath;
		if (  locationPath == thisPath && (location.hostname == this.hostname || !this.hostname) && this.hash.replace(/#/,'') ) {
			var $target = $(this.hash), target = this.hash;
			if (target) {
				var targetOffset = $target.offset().top;
				$(this).click(function(event) {
					event.preventDefault();
					$('html').animate({scrollTop: targetOffset}, 400, function() {
						location.hash = target;
					});
				});
			}
		}
	});
});
