//DROPDOWN MENU
var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}

function jsddm_close()
{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{	closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}

$(document).ready(function()
{	$('#jsddm > li').bind('mouseover', jsddm_open);
	$('#jsddm > li').bind('mouseout',  jsddm_timer);});

document.onclick = jsddm_close;


//COLORBOX
$(document).ready(function(){
	//Examples of how to assign the ColorBox event to elements
	$("a[rel='lightbox']").colorbox();
	$(".mLogin").colorbox();
	$(".mSignup").colorbox();
});


//IMAGE ROTATE
$(document).ready(function(){
	$('ul#featureBox').innerfade({
		speed: 1000,
		timeout: 5000,
		type: 'sequence',
		containerheight: '120px'
	});
	$('ul#quoteRotate').innerfade({
		speed: 1000,
		timeout: 7500,
		type: 'sequence',
		containerheight: '40px'
	});
	$('ul#pingRotate').innerfade({
		speed: 1000,
		timeout: 7500,
		type: 'sequence',
		containerheight: '40px'
	});
});

//CHECK/UNCHECK ALL
$(document).ready(function() {
	$("#checkALL").click(function(e) {
		e.preventDefault;
		return false;
	});
	$("#checkALL").click(function() {
		$("input[type='checkbox']:not([disabled='disabled'])").attr('checked', true);
	});

	$("#uncheckALL").click(function(e) {
		e.preventDefault;
		return false;
	});
	$("#uncheckALL").click(function() {
		$("input[type='checkbox']").attr('checked', false);
	});
});

//FORM SUBMIT LOADER
$(document).ready(function() {
	$('#loaderForm').bind('submit', function() {
		$('#ajax-button').hide()
		$('#ajax-loading').show()
	});
});

//SIMPLE BOOKMARK CODE
$(document).ready(function(){
	$("a.jQueryBookmark").click(function(e){
		e.preventDefault(); // this will prevent the anchor tag from going the user off to the link
		var bookmarkUrl = this.href;
		var bookmarkTitle = this.title;
	 
		if (window.sidebar) { // For Mozilla Firefox Bookmark
			window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,"");
		} else if( window.external || document.all) { // For IE Favorite
			window.external.AddFavorite( bookmarkUrl, bookmarkTitle);
		} else if(window.opera) { // For Opera Browsers
			$("a.jQueryBookmark").attr("href",bookmarkUrl);
			$("a.jQueryBookmark").attr("title",bookmarkTitle);
			$("a.jQueryBookmark").attr("rel","sidebar");
		} else { // for other browsers which does not support
			 alert('Your browser does not support this bookmark action');
			 return false;
		}
	});
});

//FACEBOOK INTEGRATION CODE
window.fbAsyncInit = function() {
	FB.init({
		appId      : '285675884802679',
		status     : true, 
		cookie     : true,
		xfbml      : true,
		oauth 		 : true
	});
	FB.Event.subscribe('auth.login', function () {
		window.location = "/login_social.php";
	});
	FB.Event.subscribe('auth.logout', function () {
		window.location = "/login_social.php?act=logout";
	});
};
(function(d){
	 var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
	 js = d.createElement('script'); js.id = id; js.async = true;
	 js.src = "//connect.facebook.net/en_US/all.js";
	 d.getElementsByTagName('head')[0].appendChild(js);
 }(document));

