$(document).ready(function(){
       /*
	$(function() {
	   $('#JYMsg').lightBox().click();
	});*/
						   
	setupFonts(); 
	fixIESelectors();
	mediasapce();
	divine_signs();
	initTabs();
	//$(document).snowfall({flakeCount:99});
$('#js-news').ticker({titleText:"Articles: ",displayType:"fade"});
$("#contact_form").validate();

$('#coda-slider-1').codaSlider();

$(".popupwindow").popupwindow();


	
});


var player;
function playerReadyCallback(obj) {
	alert('the videoplayer '+obj['id']+' has been instantiated');
	player = document.getElementById(obj['id']);
};

function concatObject(obj) {
  str='';
  for(prop in obj)
  {
    str+=prop + " value :"+ obj[prop]+"\n";
  }
  return(str);
}
(function ($) {
$.fn.simpleSpy = function (limit, interval) {
    limit = limit || 5;
    interval = interval || 4000;
    
    return this.each(function () {
        // 1. setup
            // capture a cache of all the list items
            // chomp the list down to limit li elements
        var $list = $(this),
            items = [], // uninitialised
            currentItem = limit,
            total = 0, // initialise later on
            height = $list.find('> li:first').height();
            
        // capture the cache
        $list.find('> li').each(function () {
            items.push('<li>' + $(this).html() + '</li>');
        });
        
        total = items.length;
        
        $list.wrap('<div />').parent().css({ height : height * limit });
        
        $list.find('> li').filter(':gt(' + (limit - 1) + ')').remove();

        // 2. effect        
        function spy() {
            // insert a new item with opacity and height of zero
            var $insert = $(items[currentItem]).css({
                height : 0,
                opacity : 0,
                display : 'none'
            }).prependTo($list);
                        
            // fade the LAST item out
            $list.find('> li:last').animate({ opacity : 0}, 1000, function () {
                // increase the height of the NEW first item
                $insert.animate({ height : height }, 1000).animate({ opacity : 1 }, 1000);
                
                // AND at the same time - decrease the height of the LAST item
                // $(this).animate({ height : 0 }, 1000, function () {
                    // finally fade the first item in (and we can remove the last)
                    $(this).remove();
                // });
            });
            
            currentItem++;
            if (currentItem >= total) {
                currentItem = 0;
            }
            
            setTimeout(spy, interval)
        }
        
        spy();
    });
};
    
})(jQuery);

function initTabs(){
	var tabContainer = $('#multimedia > div'); 
	tabContainer.hide().filter(':first').show();
	
	$('#tabs li a').click(function(){
				//console.log(this);
				tabContainer.hide();
				tabContainer.filter(this.hash).show();
				$('#tabs li a').removeClass('selected');
				$(this).addClass('selected');
				return false;
				
	}).filter(':first').click(0);	
}
function fixIESelectors() {
	if(jQuery.browser.msie){
		$("li:first-child").addClass("FirstChild");
		$("li:last-child").addClass("LastChild");
		$("td:last").addClass("LastChild");
		$("tr:first").addClass("FirstChild");
	}
}
function setupFonts() {
	Cufon.replace('#nav a',{hover:true});
	Cufon.replace('#subsection li',{hover:true});
	Cufon.replace('h1.sans-serif-heading');
	Cufon.replace('h2');	
	Cufon.replace('h3');
	Cufon.replace('h4');
	Cufon.replace('h5');
	Cufon.replace('#upcoming-events dd .day');
	Cufon.replace('#events-list .icon-box div.date');
	Cufon.replace('#hp-panel-02 dt');	
}
function mediasapce(){
	var flashvars = {
		xmlPath: "http://www.goharshahi.us/index.php?mediaspace" 
	};
	var params = {
	  menu: "false",
	  wmode: "transparent",
	  allowscriptaccess: "always"
	};
	var attributes = {};
	attributes.id = "mediaspace";
	swfobject.embedSWF("swf/Mediaspace.swf", "mediaspace", "648", "306", "9.0.0", false, flashvars, params, attributes);
}

function divine_signs(){
	var flashvars = {};
	var params = {
	  menu: "false",
	  wmode: "transparent"		
	};
	var attributes = {};
	attributes.id = "divine-signs-flash";
	swfobject.embedSWF("swf/divine-signs.swf", "divine-signs-flash", "606", "160", "9.0.0", false, flashvars, params, attributes);
}
