$(document).ready(function(){
	//scrollBar();
	nav();
	short_over();
	$("#top_click").floatIt('bottom');
	//$.scrollTo($('#top'), 1500);	
});

function nav()
{
	$('#nav li').hover(
		function(){$(this).addClass('ct')},
		function(){$(this).removeClass('ct')}
	);	
}

function short_over()
{
	$('.short_title').hover(
		function(){$(this).addClass('short_title_over')},
		function(){$(this).removeClass('short_title_over')}
	);	
	
	$('.short_title').click(
		function(){			
			$('.short_title').removeClass('short_title_on');
			$('.short_content').css('display', 'none');
			$(this).addClass('short_title_on');
			$(this).next().css('display', 'block');
		}
	);
}


function scrollBar()
{
	a = $('#left').height();
	b = $('#right').height();
	c = $('#center').height();
	if(a>b)
		d = a;
	else
		d = b;
		
	v = d-70;
	if(v<500) v=500;	
	
	$('#center_text').css('height', v+'px');		
}

function active(val)
{
	a = $('#nav li');
	$(a[val*2]).addClass('active_l');		
	$(a[val*2+1]).addClass('active');	
	$(a[val*2+2]).addClass('active');
}

function show_loading()
{
	$('#loading').css('display', 'block')	
}
function hide_loading()
{
	$('#loading').css('display', 'none');	
}

function step2(val, val2)
{
	hide_loading(); 
	$('#step1').slideUp();
	$('#bin_code').html(val);
	$('#bin_post').val(val);
	$('#scode').val(val2);	
	$('#step2').slideDown();
}

function search_step3(val)
{
	$.ajax({
	   type: "GET",
	   url: base+"index.php/search/step3/"+val,
	   success: function(msg){		   
			hide_loading(); 			
			if(msg=='abc')
			{
				$('#gt').html('We are sorry, you have reached the daily limit of <strong>'+limited+'</strong> queries per day. Please try again tomorrow.');
			}else{
				$('#step2').slideUp();
				$('#step3').html(msg);	
				$('#step3').slideDown();
			}
	   }
	});	
}

function re_search()
{
	refresh_code();
	$('#bin').val('');
	$('#code').val('');
	$('#scode').val('');
	$('#dcode').val('');
	$('#step3').slideUp();
	$('#step1').slideDown();
}

function refresh_code()
{
	document.getElementById('siimage').src = base+'securimage/securimage_show.php?sid=' + Math.random();	
}



jQuery.fn.floatIt = function (options) {

    //parameter like { location: "bottom" } or { location: "top" }

    // by extending the default settings, we don't modify the argument

    settings = jQuery.extend({ location: "bottom" }, options);

    var h = $(window).height();

    var w = $(window).width();

 

    var topLocation = 0;

    var leftLocation = w/2 - $(this).width()/2;

 

    var currentId = $(this).attr("id");

 

    switch (settings["location"].toLowerCase()) {
        case ("bottom"):
            //topLocation = h - $(this).width();
			
            $(window).scroll(function () {
                var topLocation = $(document).scrollTop() + $(window).height() - $("#" + currentId).height(); //closure
                $("#" + currentId).css({top: topLocation});
            });

            break;

        case ("top"):
           // topLocation = 0;
            $(window).scroll(function () {
                var topLocation = $(document).scrollTop(); //closure
                $("#" + currentId).css({top: topLocation });
            });

            break;
    }

 
	var topLocation = $(document).scrollTop() + $(window).height() - $("#" + currentId).height(); //closure
    $(this).css({ top: topLocation});

};

function gotoTop()
{
	$.scrollTo($('#head'), 1500);	
}



