/**
 * =========================================================
 * jquery.innerfade.js
 * =========================================================
 *
 * Date: 2008-12-22
 * Author: Fabian Neumann
 * Web: http://www.fabianneumann.de/
 * Web: http://www.sturzbach.de/
 *
 * Based on the works of:
 * - Medienfreunde Hofmann & Baldes GbR, Torsten Baldes, http://medienfreunde.com
 * - Matt Oakes, http://portfolio.gizone.co.uk/applications/slideshow/
 * - Ralf S. Engelschall, http://trainofthoughts.org/
 *
 * Example:
 *
 *  <ul id="news">
 *      <li>content 1</li>
 *      <li>content 2</li>
 *      <li>content 3</li>
 *  </ul>
 *
 *  $('#news').innerfade({
 *      animationtype: Type of animation 'fade' or 'slide' (Default: 'fade'),
 *      speed: Fading-/Sliding-Speed in milliseconds or keywords (slow, normal or fast) (Default: 'normal'),
 *      timeout: Time between the fades in milliseconds (Default: '2000'),
 *      containerheight: Height of the containing element in any css-height-value (Default: 'auto'),
 *      runningclass: CSS-Class which the container get�s applied (Default: 'innerfade'),
 *      next_selector: jQuery selector of element(s) that let's you manually click forward (Default: '#if-next'),
 *      prev_selector: jQuery selector of element(s) that let's you manually click backwards (Default: '#if-prev'),
 *      pause_selector: optional jQuery selector of element(s) that on hover will pause the slideshow,
 *      callback: optional function to call after each transition,
 *      children: optional children selector (Default: null),
 *  });
 *
 **/


(function($) {

    $.fn.innerfade = function(options) {
        return this.each(function() {
            $.innerfade(this, options);
        });
    };

    $.innerfade = function(container, options) {
        var settings = {
            'container': container, // container's data is used as state memory
            'animationtype': 'fade',
            'type': 'sequence',
            'speed': 'normal',
            'timeout': 2000,
            'containerheight': 'auto',
            'runningclass': 'innerfade',
            'children': null,
            'next_selector': '#if-next',
            'prev_selector': '#if-prev',
            'pause_selector': null,
            'callback': null
        };
        $.data(settings.container, 'paused', false);
        if (options)
            $.extend(settings, options);

        if (settings.children === null)
            var elements = $(container).children();
        else
            var elements = $(container).children(settings.children);

        if (elements.length < 1) return;

        if (settings.type == "sequence") {
            $.data(settings.container, 'current', 1);
            $.data(settings.container, 'last', 0);
        }

        if (settings.pause_selector !== null) {
            $(settings.pause_selector).hover(function () {
                $.data(settings.container, 'paused', true);
            }, function () {
                $.data(settings.container, 'paused', false);
            });
        }

        $(settings.prev_selector).click(function(e) {
            e.preventDefault();
            current = $.data(settings.container, 'current') - 2;
            if (current < 0) current = elements.length + current; // js modulo for negative numbers is strange (in IE)
            $.data(settings.container, 'current', current);
            $.innerfade.animate(elements, settings);
        });

        $(settings.next_selector).click(function(e) {
            e.preventDefault();
            $.innerfade.animate(elements, settings);
        });

        $(container).css('position', 'relative').css('height', settings.containerheight).addClass(settings.runningclass);
        for (var i = 0; i < elements.length; i++) {
            $(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute').hide();
        };
        if (elements.length > 1) {
            setTimeout(function() { $.innerfade.next(elements, settings); }, settings.timeout);
        }
        $(elements[0]).show();
    };

    $.innerfade.next = function(elements, settings) {
        if (!$.data(settings.container, 'paused')) {
            $.innerfade.animate(elements, settings);
        }
        setTimeout((function() {
            $.innerfade.next(elements, settings);
        }), settings.timeout);
    };

    $.innerfade.animate = function(elements, settings) {
        current = $.data(settings.container, 'current');
        last = $.data(settings.container, 'last');
        if (settings.animationtype == 'slide') {
            $(elements[last]).slideUp(settings.speed);
            $(elements[current]).slideDown(settings.speed);
        } else if (settings.animationtype == 'fade') {
            $(elements[last]).fadeOut(settings.speed);
            $(elements[current]).fadeIn(settings.speed, function() {
                removeFilter($(this)[0]);
            });
        } else {
            alert('Innerfade-animationtype must either be \'slide\' or \'fade\'');
        }

        if (typeof(settings.callback) == "function") {
            settings.callback(current, elements[current]);
        }

        $.data(settings.container, 'last', current);
        $.data(settings.container, 'current', (current + 1) % elements.length);	
    };

})(jQuery);

// **** remove Opacity-Filter in ie ****
function removeFilter(element) {
    if(element.style.removeAttribute){
        element.style.removeAttribute('filter');
    }
}


var jqs = jQuery.noConflict();
jqs.ajaxSetup({cache: false});
  
jqs("document").ready(function() {
	// for todays top stories

	jqs('#main-pri-content').load('http://www.blogadda.com/tt.php');


	// for recently updated blogs

	jqs('#tag-con').tabs();
	var fx = jqs( "#tag-con" ).tabs( "option", "fx" );
	//setter
	jqs( "#tag-con" ).tabs( "option", "fx", { opacity: 'toggle' } );
	
		
	jqs('#recent-blogs').tabs({ spinner: '<img src="images/ajax-loader.gif" alt="loader" />' });
	
	//getter
	var cache = jqs( "#recent-blogs" ).tabs( "option", "cache" );
	//setter
	jqs( "#recent-blogs" ).tabs( "option", "cache", false );
	jqs( "#recent-blogs" ).tabs({ spinner: '<img src="images/ajax-loader.gif" alt="loader" />' });
	
	jqs('#random').tabs();
	var fx = jQuery( "#random" ).tabs( "option", "fx" );
	//setter
	jqs( "#random" ).tabs( "option", "fx", { opacity: 'toggle' } );


	jqs('#random').tabs();
	var fx = jQuery( "#tag-cats" ).tabs( "option", "fx" );
	//setter
	jqs( "#random" ).tabs( "option", "fx", { opacity: 'toggle' } );


	//this is blog recommend
	jqs('.recomm_refresh').click(function()
	{
		jqs('.inner').css( "visibility","hidden");
		jqs('#rec-panel').hide();
		jqs('#sub').hide();
		jqs(".recomm_down_arr").html('<img border="0" src="http://www.blogadda.com/images/utab_down_arr.jpg" alt="down arrow" />');
		jqs('#screen').css({	"display": "block", opacity: 0.6, "z-index": "1000", "width":jqs(document).width(),"height":jqs(document).height()});		
		jqs('.top_hover_box').show();			
	});
	jqs(document).mouseup(function(e) {
	 	jqs(".top_hover_box").hide();
	   jqs("#screen").hide();
   });
   jqs(".top_hover_box").mouseup(function(e) {
	   return false;
   });
	jqs(document).keydown(function(e) {
	if (e.keyCode == 27) {
		jqs(".top_hover_box").hide();
	        jqs("#screen").hide();
	}
	});

	//for loading title and refresh on real time 
	jqs("#recomm_title").load("http://www.blogadda.com/bareclist");
/*	var refreshId = setInterval(function() {
		//alert('ok');	
		jqs("#recomm_title").load("http://www.blogadda.com/bareclist");
	}, 5000);*/
		
		//for toolbar show and hide
	jqs("#toolbar").click(function(){
			jqs("#uberbar").slideToggle(100);
			jqs("#sub").hide();
			jqs("#rec-panel").hide();
			jqs("#clickshow").show();
			jqs(".recomm_down_arr").html('<img border="0" src="http://www.blogadda.com/images/utab_down_arr.jpg" alt="up arrow" />');
		});
	jqs("#clickshow").click(function(){
		jqs("#uberbar").slideToggle(100);
		jqs("#clickshow").hide();
			return false;
	});
		
		// for dropdown effect	
	jqs('#rec-link').toggle(function(e)
	{
		jqs("#rec-panel").load("http://www.blogadda.com/baRecPanel");
		jqs(".recomm_down_arr").html('<img border="0" src="http://www.blogadda.com/images/utab_up_arr.jpg" alt="up arrow" />');	
		jqs("#sub").show();
		jqs('.inner').css( "visibility","hidden");
	   jqs("#rec-panel").show();                           
  	 }, function() {
		jqs(".recomm_down_arr").html('<img border="0" src="http://www.blogadda.com/images/utab_down_arr.jpg" alt="down arrow" />');
		jqs("#sub").hide();			 
		jqs("#rec-panel").hide();
      //evt.preventDefault();
	});



	jqs('#pillars').mouseup(function(e) {
			jqs(".recomm_down_arr").html('<img border="0" src="http://www.blogadda.com/images/utab_down_arr.jpg" alt="down arrow" />');
			jqs("#sub").hide();			 
			jqs("#rec-panel").hide();
	}); 
	jqs("#rec-link").mouseup(function(e) {
		return false;
	});
	jqs("#rec-panel").mouseup(function(e) {
		return false;
	});
	
	/* for tool bar */
	jqs(".recomm_remove").click(function(){
		jqs.post("http://www.blogadda.com/tracktoolbar", {status: 'hide'}, function(data){
			//alert(data);	 
		});
		jqs("#uberbar").hide();
		jqs("#hidding").show();
		jqs("#showlink").show();
	});
	jqs("#showlink").click(function(){
		jqs("#hidding").hide();	
		jqs("#uberbar").show();
		jqs("#clickshow").show();
		jqs.post("http://www.blogadda.com/tracktoolbar", {status: 'show'}, function(data){
			//alert(data);	 
		});
		jqs("#showlink").hide();
	});
	
	/*	jqs("#recently_updated").load("http://www.blogadda.com/recently_updated.php"); // code for recently updated blogs
		jqs('#hourly').toggle(function() {
			jqs('#hourly').text('Editor');
			jqs("#recently_updated").html('<div id="NewsVertical"><img class="ref" src="http://www.blogadda.com/images/loading.gif" alt="Wait" /></div>');	
	        jqs("#recently_updated").load("http://www.blogadda.com/recently_updated1.php");  

     	 }, function() {
			jqs('#hourly').text('Regular');
		jqs("#recently_updated").html('<div id="NewsVertical"><img class="ref" src="http://www.blogadda.com/images/loading.gif" alt="Wait" /></div>');	
        jqs("#recently_updated").load("http://www.blogadda.com/recently_updated.php");                                     //load on click refresh
		});
	*/
		jqs('#tag-cat').load("http://www.blogadda.com/baTagCat");
		jqs("#randomdiv").html('<img class="ref" src="http://www.blogadda.com/images/loading.gif" alt="Wait" />');
		//jqs("#randomdiv").load("tweettry2.php");                                     //load on domready
		/*var refreshId = setInterval(function() {
			jqs("#randomdiv").html('<img class="ref" src="http://www.blogadda.com/images/loading.gif" alt="Wait" />');
			jqs("#randomdiv").load('tweettry2.php');
		}, 100000);*/
		
		jqs('#hot_post').innerfade({
		animationtype: 'fade',
		speed: 'slow',
		timeout: 6000,
		type: 'sequence',
		containerheight: 'auto',
		pause_selector: '#hot_post',
	});		
});


//Accordion effect for BSR

jqs(document).ready(function(){
	
//Set default open/close settings
jqs('.acc_container').hide(); //Hide/close all containers
jqs('.acc_trigger:first').addClass('active').next().hide(); //Add "active" class to first trigger, then show/open the immediate next container

//On Click
jqs('.acc_trigger').click(function(){
	if( jqs(this).next().is(':hidden') ) { //If immediate next container is closed...
	jqs('.acc_trigger').removeClass('active').next().slideUp(); //Remove all .acc_trigger classes and slide up the immediate next container
	jqs(this).toggleClass('active').next().slideDown(); //Add .acc_trigger class to clicked trigger and slide down the immediate next container
	}
	return false; //Prevent the browser jump to the link anchor
});

});


jqs("document").ready(function() {
		jqs('#NewsVertical').load("http://www.blogadda.com/recent.php?category=regular"); //load hourly
		/*jqs("#refresh").click(function(evt) {
		jqs("#randomdiv").html('<img class="ref" src="http://www.blogadda.com/images/loading.gif" alt="Wait" />');	
      //   jqs("#randomdiv").load("tweettry2.php")                                     //load on click refresh
         evt.preventDefault();
      });
      //footer opacity

				//settings
				var opacity = 0.3, toOpacity = 1.9, duration = 250;
				//set opacity ASAP and events
				jqs('.opacity').css('opacity',opacity).hover(function() {
						jqs(this).fadeTo(duration,toOpacity);
					}, function() {
						jqs(this).fadeTo(duration,opacity);
					}
				);
		*/
		// recent tab details
		jqs("#random").load("http://www.blogadda.com/regular-tabs1.php");    

    	jqs('#ref').toggle(function()
		 {
		jqs('#ref').text('Sort by Popular');
		jqs("#random").html('<img class="ref" src="http://www.blogadda.com/images/loading.gif" alt="Wait" />');	
        jqs("#random").load("http://www.blogadda.com/regular-tabs.php");                                     //load on click refresh
        evt.preventDefault();

     	 }, function() {
			jqs('#ref').text('Sort by All');
		jqs("#random").html('<img class="ref" src="http://www.blogadda.com/images/loading.gif" alt="Wait" />');	
        jqs("#random").load("http://www.blogadda.com/regular-tabs1.php");                                     //load on click refresh
		 
         evt.preventDefault();
		} 

);




      //footer opacity

				//settings
				var opacity = 0.3, toOpacity = 1.9, duration = 250;
				//set opacity ASAP and events
				jqs('.opacity').css('opacity',opacity).hover(function() {
						jqs(this).fadeTo(duration,toOpacity);
					}, function() {
						jqs(this).fadeTo(duration,opacity);
					}
				);
});

// for slide in/out panel

var jqmenu = jQuery.noConflict();

jqmenu(window).load(function (){
	document.getElementById('login-link').href="#";
	jqmenu("#login-link").click(function(){
		jqmenu("#login-panel").slideToggle(200);
	});
	jqmenu(document).mouseup(function(e) {
		jqmenu("#login-panel").hide();
	});
	jqmenu("#login-panel").mouseup(function(e) {
		return false;
	});
	jqmenu("#login-link").mouseup(function(e) {
		return false;
	});
		
});

// for perky
jqmenu(document).ready(function (){
	jqmenu("#ptis-content").click(function(){
		jqmenu("#inner").slideToggle(200);
		jqmenu("#inner1").hide();
		jqmenu("#inner2").hide();
		jqmenu("#inner3").hide();
		jqmenu("#inner4").hide();
		jqmenu("#inner5").hide();	
	});
	jqmenu(document).mouseup(function(e) {
		jqmenu("#inner").hide();
	});
	jqmenu("#inner").mouseup(function(e) {
		return false;
	});
	jqmenu("#ptis-content").mouseup(function(e) {
		return false;
	});
	jqmenu("#inner_close").click(function(){
	jqmenu("#inner").hide();			
	});	
		
});


// for tangy
jqmenu(document).ready(function (){
    jqmenu("#ptis-content1").click(function(){
        jqmenu("#inner1").slideToggle(200);
		jqmenu("#inner").hide();
		jqmenu("#inner2").hide();
		jqmenu("#inner3").hide();
		jqmenu("#inner4").hide();
		jqmenu("#inner5").hide();
    });
    jqmenu(document).mouseup(function(e) {
        jqmenu("#inner1").hide();
    });
    jqmenu("#inner1").mouseup(function(e) {
        return false;
    });
    jqmenu("#ptis-content1").mouseup(function(e) {
        return false;
    });
	jqmenu("#inner_close1").click(function(){
	jqmenu("#inner1").hide();			
	});
}); 


// for interview
jqmenu(document).ready(function (){
    jqmenu("#ptis-content2").click(function(){
        jqmenu("#inner2").slideToggle(200);
		jqmenu("#inner").hide();
		jqmenu("#inner1").hide();	
		jqmenu("#inner3").hide();
		jqmenu("#inner4").hide();
		jqmenu("#inner5").hide();
    });
    jqmenu(document).mouseup(function(e) {
        jqmenu("#inner2").hide();
    });
    jqmenu("#inner2").mouseup(function(e) {
        return false;
    });
    jqmenu("#ptis-content2").mouseup(function(e) {
        return false;
    });
	jqmenu("#inner_close2").click(function(){
	jqmenu("#inner2").hide();			
	});
}); 

// spicy 
jqmenu(document).ready(function (){
    jqmenu("#ptis-content3").click(function(){
        jqmenu("#inner3").slideToggle(200);
		jqmenu("#inner").hide();
		jqmenu("#inner1").hide();
		jqmenu("#inner2").hide();	
		jqmenu("#inner4").hide();
		jqmenu("#inner5").hide();
    });
    jqmenu(document).mouseup(function(e) {
        jqmenu("#inner3").hide();
    });
    jqmenu("#inner3").mouseup(function(e) {
        return false;
    });
    jqmenu("#ptis-content3").mouseup(function(e) {
        return false;
    });
	jqmenu("#inner_close3").click(function(){
	jqmenu("#inner3").hide();			
	});
}); 

// contest
jqmenu(document).ready(function (){
    jqmenu("#ptis-content4").click(function(){
        jqmenu("#inner4").slideToggle(200);
		jqmenu("#inner").hide();
		jqmenu("#inner1").hide();
		jqmenu("#inner2").hide();
		jqmenu("#inner3").hide();	
		jqmenu("#inner5").hide();
    });
    jqmenu(document).mouseup(function(e) {
        jqmenu("#inner4").hide();
    });
    jqmenu("#inner4").mouseup(function(e) {
        return false;
    });
    jqmenu("#ptis-content4").mouseup(function(e) {
        return false;
    });
	jqmenu("#inner_close4").click(function(){
	jqmenu("#inner4").hide();			
	});
}); 

// tips
jqmenu(document).ready(function (){
    jqmenu("#ptis-content5").click(function(){
        jqmenu("#inner5").slideToggle(200);
		jqmenu("#inner").hide();
		jqmenu("#inner1").hide();
		jqmenu("#inner2").hide();
		jqmenu("#inner3").hide();	
		jqmenu("#inner4").hide();	
	
    });
    jqmenu(document).mouseup(function(e) {
        jqmenu("#inner5").hide();
    });
    jqmenu("#inner5").mouseup(function(e) {
        return false;
    });
    jqmenu("#ptis-content5").mouseup(function(e) {
        return false;
    });
	jqmenu("#inner_close5").click(function(){
	jqmenu("#inner5").hide();			
	});
});

jqmenu(document).ready(function (){
	//document.getElementById('search-link').href="#";
	jqmenu("#search-link").click(function(){
		jqmenu("#search-panel").slideToggle(200);
	});
	jqmenu(document).mouseup(function(e) {
		jqmenu("#search-panel").hide();
	});
	jqmenu("#search-panel").mouseup(function(e) {
		return false;
	});
	jqmenu("#search-link").mouseup(function(e) {
		return false;
	});
});	


jqmenu(document).ready(function (){
	jqmenu("#addlist").click(function(){
		jqmenu("#addlist-panel").toggle();
	});
	jqmenu(document).mouseup(function(e) {
		jqmenu("#addlist-panel").hide();
	});
	jqmenu("#addlist-panel").mouseup(function(e) {
		return false;
	});
	jqmenu("#addlist").mouseup(function(e) {
		return false;
	});
});	

function loadtagcat(typ){
	jqs('#tag-cat').load("http://www.blogadda.com/baTagCat?tabnumfetch="+typ);
}


function loadlike(){
	jqs('#tag-cat').load("http://www.blogadda.com/baTagCat");
}


function showhupdates(thecat){
	if(thecat == 'viewall')
	{
		window.location.href = "http://www.blogadda.com/updatedindianblogs";	
	}
	else
	{
		jqs('#NewsVertical').load("http://www.blogadda.com/recent.php?category="+thecat); //load hourly	
	}	
}

jQuery(document).ready(function() {
	keywords = [ "news", "bollywood", "lifestyle", "comics", "food", "travel", "hindi" ]
	var keyword = keywords[Math.floor(Math.random()*keywords.length)] ;
	jQuery('#loadhp').load('http://www.blogadda.com/maintab1.php?cat='+keyword);
});

function doshowhp(thetype)
{
	//alert(thetype);
	jQuery('#loadhp').load('http://www.blogadda.com/maintab1.php?cat='+thetype);
}

function showviewall(){
	
		window.location.href = "http://www.blogadda.com/updatedindianblogs";	
		
}

function showcricket(){
	
window.open('http://cricket.blogadda.com');	
		
}

function loaduavatar(typ){
	jqs('#auto').load("http://www.blogadda.com/display-avatar.php?ngoid="+typ);
}

function social_blogpost(ngo_id)
{

	jQuery('#social_bp').load('http://www.blogadda.com/display-socialbp.php?ngoid='+ngo_id);
}

function load_toolbar()
{
	jQuery("#recomm_title").load("http://www.blogadda.com/bareclist");
}
