$.fn.listManager=function (obj){
	$(this).parent().each(function(index){
		var selectorLength=$(this).children().length;
		var numRows=selectorLength/obj.columns;
		var extras=selectorLength%obj.columns;
		var j=1;
		$(this).children().each(function(index){		
			if((obj.columns*j-1)==index){
				$(this).addClass(obj.LastRow);
				j++;
			}
			if(index > selectorLength-obj.columns-1 && extras==0)
			{
				$(this).addClass(obj.BottomRow);
				return;
			}
			else if(index > selectorLength-extras-1){
				$(this).addClass(obj.BottomRow);
			}				
		});				
	});
			
}

$.fn.initVal = function(value) {
	$(this).val(value);
	$(this).focus(function(){
		if($(this).val()==value){$(this).val('')}
	});
	$(this).blur(function(){
		if($(this).val()==''){$(this).val(value)}
	});
}

function dotimer(getFocused,getLi_csTab){
		//console.log(getLi_csTab.length+'='+$(getLi_csTab).index(getFocused));
		if((getLi_csTab.length-1)==$(getLi_csTab).index(getFocused))
		{
			$(getLi_csTab[0]).click();
		}
		else{
			$(getFocused).next('li').click();
		}
}
		
$.fn.customTabs = function(options) {
	var opts = $.extend({}, $.fn.customTabs.defaults, options);
	var par=$(this);
	getLi_csTab=$(" > ul li", this);
	$(" > ul li:first", this).addClass('focus');
	$(" > div:first", this).show();
	getFocused=$(" > ul li.focus", this);
	$(" > ul li", this).click(function(){
		var wrapper=$(this).parent().parent()
		var getIndex=$(wrapper).find("> ul li").index(this);
		$(wrapper).find("> ul li").removeClass('focus');
		$(this).addClass('focus');
		getFocused=$(this);
		$(wrapper).find(" > div").fadeOut('slow');
		//$(this+' > div:eq('+getIndex+')').show();
		$(wrapper).find(" > div:eq("+getIndex+")").fadeIn('slow');		
	});
	if(opts.auto==true){		
		setTimer=setInterval("dotimer(getFocused,getLi_csTab)",opts.duration);
		$(this).hover(function(){clearInterval(setTimer)},function(){setTimer=setInterval("dotimer(getFocused,getLi_csTab)",opts.duration);})
	}
}

$.fn.customTabs.defaults = {
		auto: false,
		duration: 4000
	};

$.fn.bastabs = function() {
	var par=$(this);
	$(" > ul li:first", this).addClass('focus');
	$(" > div:first", this).show();
	$(" > ul li", this).click(function(){
		var wrapper=$(this).parent().parent()
		var getIndex=$(wrapper).find("> ul li").index(this);
		$(wrapper).find("> ul li").removeClass('focus');
		$(this).addClass('focus');
		$(wrapper).find(" > div").hide();
		//$(this+' > div:eq('+getIndex+')').show();
		$(wrapper).find(" > div:eq("+getIndex+")").show();
		
	});			
}
//Eg: $(selector).tabs();

$.fn.fancyRadio = function() {
	this.click(function(){
		$(this).siblings().removeClass("checked");
		$(this).addClass("checked");
		$('input:radio',this).attr('checked', true)
		var el=$(this);
	});
}
$.fn.fancyCheckBox=function() {
	this.click(function(){
		$(this).toggleClass("checked");
		if($(this).hasClass('checked')){
			$('input:checkbox',this).attr('checked', true);
		}
		else{
			$('input:checkbox',this).attr('checked', false);
		}
		var el=$(this);
	});
}

$.fn.smoothScroll=function(delay) {	
	this.click(function() {
		elementClicked = $(this).attr("rel"), destination = $(elementClicked).offset().top;
		var action="$('html:not(:animated),body:not(:animated)').animate({ scrollTop: destination-5}, 'slow' )"
		if(delay==undefined){setTimeout(action,0)}
		else{setTimeout(action,delay)}
	});
}

function tabPointer(tab, data){
	$(tab).click(function(){
		var getIndex=$(tab).index(this);
		alert(getIndex);
		$(data).hide();
		$(data+':eq('+getIndex+')').show();
	});
}



function tabPointer(b,c){$(b).click(function(){var a=$(b).index(this);$(c).hide();$(c+':eq('+a+')').show()})};


function setBlock(selector, wrapper, numBlocks){
	var num=$(selector), wrapx=[];
	for (m=0; m<num.length; m+=numBlocks)
	{
	for(var i=0, n=m; i<numBlocks; i++, n++)
	{
	wrapx[i]=num[n];
	}
	$(wrapx).wrapAll(wrapper);
	}
}


/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-07-21 18:45:56 -0500 (Sat, 21 Jul 2007) $
 * $Rev: 2447 $
 *
 * Version 2.1.1
 */
(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);
