jQuery.fn.sprites = function(settings) {
	settings = jQuery.extend({
		allowClick: true,
		show: {opacity: 'show'},
		hide: {opacity: 'hide'},
		active: 'active',
		click: 'click'
	}, settings);
	this.addClass('spritesnav');
	this.children("li").children("a").fadeTo(0,0).show();
	
	// Attach events to each child
	jQuery(this).children().each(function(){		

		// Do not attach events to active children

			//hide the css defined :hover background

			jQuery(this).hover(function() {
			
				jQuery(this).children('a').fadeTo(400,1); 
				

				}, function() {
			jQuery(this).children('a').fadeTo(400,0); 
			}
			);
		
			//click events on the a if allowClick is true
		
		
	});
};

jQuery.fn.spritesli = function() { 

// Attach events to each child
		
	jQuery(this).children('ul').children('li').each(function(){	
		jQuery(this).children('ul').children('li').hover(function() {	
			jQuery(this).children('ul').children('li').children('div').children('a').animate({ 
		        backgroundColor: "#000000"},500);
				
		});
	
	
	});
};




	$(document).ready(function(){
		$('#topmenuid').sprites({
				allowClick: false,
			show: {width: 'show', height: 'show'},
			hide: {width: 'hide'}
		});
		$('#slider').spritesli();
	
	});
	
	//Ajax pager
jQuery.fn.ajaxpager = function(all, ongotopage,objid) {
var page=1;
var cpage=1;

if(objid!='') {
obj=$(objid); 
}

	
$("#prevp").addClass("not");

// changed

	gotopage = function (from_p,to_p) {
			for(i=from_p; i<to_p;i++ ) {
			$('#'+i).removeClass().addClass('nxcurp');
			}
		$('#'+to_p).removeClass().addClass('curp');	
		for(i=1+parseInt(to_p); i<=from_p;i++ ) { 
			$('#'+i).removeClass().addClass('prcurp');
			}
			if(to_p==1) $("#prevp").addClass("not");
			if(from_p==1)$("#prevp").removeClass("not");
			if(to_p==all) $("#nextp").addClass("not");
			if(from_p==all)$("#nextp").removeClass("not");
			//loaddiv
	if(objid!='') obj.html('<div class="loaddiv"><img src="assets/images/loading.gif"></div>');	
		ongotopage(to_p,from_p);
  cpage=to_p;
  page=to_p;
	return to_p;

	}
	
	//detect direct url

	if(location.hash!='') {
		var reg=/#page(\d*)/;
		var arr; arr=reg.exec(location.hash);
		if(arr && parseInt(arr[1]) && arr[1]!=1 ) {
			page=arr[1];
			gotopage(1,arr[1]); 
			}
		}
	jQuery(this).children().each(function(){	
		jQuery(this).click(function() {	
		cpage=page;
		if (this.id =="prevp" && page>1) {
		page--;
		}
		else if(this.id =="nextp" && page<all) {
		page++;
	
		} else if( parseInt(this.id)) page=this.id;
	
    if(cpage!=page) {
			page=gotopage(cpage,page);
			location.hash="#page"+page; 

			}
				
		});
	
	
	});
	//alert(location.hash);

};
// main image tooltip
$(document).ready(function(){
jQuery('#mainimg').children('div').fadeTo(0,0).show(0);


$('#mainimg').hover(
function() {
jQuery(this).children('div').fadeTo(350,1);

 },
function() {
jQuery(this).children('div').fadeTo(0,0);
	}
);


	
	
});



