$(document).ready(function(){
	$("#viewmore_btn").click(function() {
		$("#viewmore").slideDown('slow');
		$("#viewmore_btn").css('display', 'none');
		$("#viewless_btn").css('display', 'block');
	});
	$("#viewless_btn").click(function() {
		$("#viewmore").slideUp('slow');
		$("#viewmore_btn").css('display', 'block');
		$("#viewless_btn").css('display', 'none');
	});

	// FS jq plugin
	$("#chained").scrollable({hoverClass: 'hover'}).circular().navigator().mousewheel().autoscroll({
		steps: 3,
		interval: 3000		
	});	

	// side menu tabs jq plugin
	$("#accordion").tabs("#accordion div.pane", {
		tabs: 'h2', 
		effect: 'slide', 
		initialIndex: null
	});

	$("#content_pages").tabs("#content_pages div.row", {
		tabs: 'h2', 
		effect: 'slide', 
		initialIndex: null
	});

	$("#apple img[rel]").overlay({effect: 'apple'}); 
});

function padlength(what){
	var output=(what.toString().length==1)? "0"+what : what;
	return output;	
}

function SlideMe(id)
{
	$("#slideme" + id).slideToggle("fast");
}

function GoToLocation(url)
{
	document.location = url;
}

function DoTooltip(id, con, Element, x, y, clickR)
{	
	$("#tooltip-" + id).easyTooltip({
		xOffset: x,		
		yOffset: y,
		tooltipId: "easyTooltip-jq",
		clickRemove: clickR,
		content: con,
		useElement: Element
	});
}
	
function showHint(str)
{ 
	if (str.length==0)
	{ 
		document.getElementById("spanHints").innerHTML = "";
		return;
	}
				
	var url="gethint.php?query=" + encodeURI(str) + "&num="+Math.random();
		
	http.open("get",url,true);
		
	http.onreadystatechange=stateChanged;
	http.send(null);	
} 

function stateChanged() 
{ 
	var response;
	var str = "";
	var splitted = "";
	//get response from the server
	if (http.readyState==4) 
	{
		if (typeof(http.responseText)=="unknown")
		{
		}
		else
		{
			response = http.responseText.split("|");
			str = "<table bgcolor=#F7F5F6>";
			
			for (i=0;i<response.length; i++)
			{
				splitted = response[i].split("#");
				splitted[0].replace("&039;","'");
				str = str + "<tr>" + "<td>" + "<a href=" +  "'" + splitted[1] + "'" + ">" + splitted[0] + "</a>" + "</td>" + "</tr>";

			}
			
			str = str + "</table>";
			document.getElementById("spanHints").innerHTML = str;
		}
	}
}
	
function createRequestObject()
{
	var ro;
        var browser = navigator.appName;
        if(browser == "Microsoft Internet Explorer")
        {
			ro = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else
        {
			ro = new XMLHttpRequest();
        }
        return ro;
}

var http = createRequestObject();

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
    jQuery('#bold-items').jcarousel({
        auto: 2,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });
    jQuery('#more-seller-items').jcarousel({
	vertical: true,
	scroll: 5
    });
});

function OpenFaceBox(name, id)
{
	$("#" + name + id).overlay({ 
		top: 272, 
		expose: { 
			color: '#fff', 
			loadSpeed: 200, 
			opacity: 0.5 
		}, 
		closeOnClick: false, 
		api: true 
	}).load();
}
