/* * © Altamira Softworks, ltd 2006 - 2010 * info@altamira.sk | http://www.altamira.sk * All Rights Reserved * */ $().ready(function() { var hsh = window.location.hash; if (hsh!='') { $('.tab').removeClass('active'); $('.asscript_tab').hide(); var ajaxlink = $("a[rel='"+hsh+"']").attr('href'); $('a[href$="'+hsh+'"]').parent().addClass('active'); if(typeof(ajaxlink)!='undefined') { processTab($("a[rel='"+hsh+"']")); } else { processTab($('a[href$="'+hsh+'"]')); } } else { $('.asscript_tabs .asscript_tab:first').show(); } $('.tabcontainter .tab a').click(function(e) { e.preventDefault(); processTab($(this)); }); }); function processTab(obj) { $('.tabcontainter li').removeClass('active'); obj.parent().addClass('active'); $('.asscript_tab').hide(); var parser = obj.attr('href').split('#'); var atab = '#'+parser[1]; if(strpos(atab,'#')!==false) { // just show hidden div $("div[rel='"+atab+"']").fadeIn(); } else { // ajax call var rel = obj.attr('rel'); if(rel==undefined) { document.location=atab; } else { ajaxCall(atab,rel); } } } // @ call ajax function ajaxCall(link,target_id,method) { if(typeof(method)=='undefined') method='GET'; xhr = $.ajax({ url: link, cache: false, type: method, success: function(html){ $("div[rel='"+target_id+"']").html(html).hide().fadeIn(); } }); } // @ PHP-like strpos function function strpos (haystack, needle, offset) { var i = (haystack + '').indexOf(needle, (offset || 0)); return i === -1 ? false : i; }