
jQuery(document).ready(function(){

var rand_no = Math.random();
rand_no = rand_no * 3;
rand_no = Math.ceil(rand_no);

jQuery(".neprehlednete p").hide();  

showRandom(rand_no);
  $('body:not(.single-portfolio) .type-portfolio.hentry p.description').ThreeDots({ max_rows: 3 });


function showRandom(r){
jQuery(".neprehlednete p." + r + "").show();
jQuery(".neprehlednete h2." + r + "").addClass("hover");
}

jQuery(".neprehlednete h2").click(function(){
  var classa = jQuery(this).attr("class");
  showPara(classa);
});

function showPara(a){
jQuery(".neprehlednete p").hide();
  jQuery(".neprehlednete h2").removeClass("hover");
  jQuery(".neprehlednete p." + a + "").show();
  jQuery(".neprehlednete h2." + a + "").addClass("hover");  
}

jQuery(function() {
/*	$.getJSON("/devtest/wp-content/themes/netwits/search/suggestions.txt",
		function(data){
			$('input.vyhledavani').jsonSuggest(data, {maxResults:20});
		}
	);  */

$('input.vyhledavani').jsonSuggest(testData.webSites, {onSelect:callback});

/* $('input.vyhledavani').jsonSuggest(
		function(text, wildCard, caseSensitive, notCharacter) {
			// From here you can put your own logic in to say what results show.
			// For now I'm just going to return some dummy data.
			
			return [
				{text:'Webdesign'}
			];
		}, {ajaxResults:true}, {maxResults:5}); */   
		
	$('.jsonSuggestResults').css("width","185px");

});  

function callback(item) {
	if(JSON.stringify(item.extra) != "undefined"){
	var str = JSON.stringify(item.extra);
  var url = str.substring(1, str.length-1);
      window.location.href = url;
  }
}
	
});	

var testData = {};
	
// JSON string, could get this from anywhere
// The object that the JSON string should represent, can use this as it is if you want.
testData.webSites = [
	{
		id: 1,
		text: 'Webdesign',
		extra: '/kompletni-tvorba-www-stranek/'
	},
	{
		id: 2,
		text: 'SEO',
		extra: '/seo/'
	},
	{
		id: 3,
		text: 'Ceník',
	},
	{
		id: 4,
		text: 'CMS',
	},
	{
		id: 5,
		text: 'Herni.cz',
		image: 'http://herni.cz/favicon.ico',
		extra: '/reference/herni-cz/'
	},
  	{
		id: 6,
		text: 'Osmikráska.cz',
		image: 'http://osmikraska.cz/image/favicon.gif',
		extra: '/reference/osmikraska-cz/'
	},
  	{
		id: 7,
		text: 'Yerba maté',
		image: '/wp-content/themes/netwits/img/random.gif',
		extra: '/reference/yerba-mate/'
	}];
	
// JSON string of the above object, just as an example
testData.webSitesJSON = JSON.stringify(testData.webSites);

