// JavaScript Document
$(function ($) {
			
	$("div.fcol1-2 li a").addClass("aflinks");		
			$("div.fcol1-1 li a").addClass("aflinks");
			$("div.fcol2 ul.levelone li a").addClass("aflinks");
			
			
	$("div.ngg-widget img").wrap("<span class='img_wrapper' />");		
	// Load dialog on page load
	//$('#basic-modal-content').modal();

	$('div.account_links div.already_account').hover(function(){
							$(this).addClass('already_account_hover');										  
										  },
									function(){
										$(this).removeClass('already_account_hover');
										});
		$('div.account_links div.personal_account').hover(function(){
							$(this).addClass('personal_account_hover');										  
										  },
									function(){
										$(this).removeClass('personal_account_hover');
										});
		
	$('div.account_links div.business_account').hover(function(){
							$(this).addClass('business_account_hover');										  
										  },
									function(){
										$(this).removeClass('business_account_hover');
										});
	
	
	// Load dialog on click
	$('a.yes_i_prayed').click(function (e) {
		$('#ijust_prayed').modal();
		return false;
	});
	$('a.i_have_question').click(function (e) {
		$('#ihavequestion').modal();
		return false;
	});
});

function mytabe(ids)
{
	var tab = new Array("page1","page2");
	var tabss = new Array("tab1","tab2");
	for (var i in tab)
	{
		if(tab[i] == ids)
		{  
			$('#'+tabss[i]).addClass("selected");
			$('#'+tab[i]).show();
		} else 
		{
			$('#'+tab[i]).hide();
			$('#'+tabss[i]).removeClass("selected");
		}
	}
}

$(document).ready(function()
{
	$('#slidemargin').click(function()
	{
		if (getright())
		{
			$(".storize").animate({"right": "-518px"}, "slow");
		} else {
			$(".storize").animate({"right": "0px"}, "slow");
		}
	});
	
	$('#mycarousel').jcarousel();
	
});
function getright()
{
	var vause = $(".storize").css("right");
	if(vause == "0px")
	{
		return true;
	} else {
		return false;
	}
}

function hover(id,cases)
{
	//alert( $(id).css("width") );
	if(cases == "on")
	{
		$(id).fadeIn("slow");
	} else {
		$(id).fadeOut("slow");	
	}
}
	$('.blocks').mouseover(function(e)
	{
		e.stopPropagation();
	});	
	// col




/*Cufon.replace('.myriad_pro_semibold_italic', { fontFamily: 'Myriad Pro Semibold Italic', hover: true }); 
Cufon.replace('.myriad_pro_semibold', { fontFamily: 'Myriad Pro Semibold', hover: true }); 
Cufon.replace('.myriad_pro_regular', { fontFamily: 'Myriad Pro Regular', hover: true }); 
Cufon.replace('.myriad_pro_condensed_italic', { fontFamily: 'Myriad Pro Condensed Italic', hover: true }); 
Cufon.replace('.myriad_pro_condensed', { fontFamily: 'Myriad Pro Condensed', hover: true }); 
Cufon.replace('.myriad_pro_bold_italic', { fontFamily: 'Myriad Pro Bold Italic', hover: true }); 
Cufon.replace('.myriad_pro_bold_condensed_italic', { fontFamily: 'Myriad Pro Bold Condensed Italic', hover: true }); 
Cufon.replace('.myriad_pro_bold_condensed', { fontFamily: 'Myriad Pro Bold Condensed', hover: true }); 
Cufon.replace('.myriad_pro_bold', { fontFamily: 'Myriad Pro Bold', hover: true }); 


Cufon.replace('.aflinks', { fontFamily: 'Helvetica', hover: true });
Cufon.replace('div.panel-content p', { fontFamily: 'Helvetica', hover: true }); 
Cufon.replace('div.post div.entry h2', { fontFamily: 'Helvetica', hover: true }); 
Cufon.replace('div.post div.entry h3', { fontFamily: 'Helvetica', hover: true });
Cufon.replace('h3.blog_title', { fontFamily: 'Helvetica', hover: true });
Cufon.replace('div.entry h2', { fontFamily: 'Helvetica', hover: true });
Cufon.replace('div.sub a', { fontFamily: 'Helvetica', hover: true });
Cufon.replace('div.contact_middle p', { fontFamily: 'Helvetica', hover: true });
Cufon.replace('div.about_zmenu_left p', { fontFamily: 'Helvetica', hover: true });
Cufon.replace('div.about_zmenu_right p', { fontFamily: 'Helvetica', hover: true });

*/
$(document).ready(function() {
   function megaHoverOver(){
      $(this).find(".sub").stop().fadeTo('fast', 1).show();         
      //Calculate width of all ul's
      (function($) { 
         jQuery.fn.calcSubWidth = function() {
            rowWidth = 0;
            //Calculate row
            $(this).find("ul").each(function() {               
               rowWidth += $(this).width(); 
            });   
         };
      })(jQuery);       
      if ( $(this).find(".row").length > 0 ) { //If row exists...
         var biggestRow = 0;   
         //Calculate each row
         $(this).find(".row").each(function() {                        
            $(this).calcSubWidth();
            //Find biggest row
            if(rowWidth > biggestRow) {
               biggestRow = rowWidth;
            }
         });
         //Set width
         $(this).find(".sub").css({'width' :biggestRow});
         $(this).find(".row:last").css({'margin':'0'});
         
      } else { //If row does not exist...
         
         $(this).calcSubWidth();
         //Set Width
         $(this).find(".sub").css({'width' : rowWidth});         
      }
   }   
   function megaHoverOut(){ 
     $(this).find(".sub").stop().fadeTo('fast', 0, function() {
        $(this).hide(); 
     });
   }
   var config = {    
       sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
       interval: 0, // number = milliseconds for onMouseOver polling interval    
       over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
       timeout: 200, // number = milliseconds delay before onMouseOut    
       out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
   };

   $("ul#topnav li .sub").css({'opacity':'0'});
   $("ul#topnav li").hoverIntent(config);
   
   /* Fade in bg of parent li's
   $("#toolbar").hover(function () {
       $(".image").fadeOut("slow", function () {
           $(this).addClass("imagehover").fadeIn("slow", function () {
               $(this).removeClass("imagehover");
           });
       });
   
   });*/
   
});

var BrowserDetect = {
   init: function () {
      this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
      this.version = this.searchVersion(navigator.userAgent)
         || this.searchVersion(navigator.appVersion)
         || "an unknown version";
      this.OS = this.searchString(this.dataOS) || "an unknown OS";
   },
   searchString: function (data) {
      for (var i=0;i<data.length;i++)   {
         var dataString = data[i].string;
         var dataProp = data[i].prop;
         this.versionSearchString = data[i].versionSearch || data[i].identity;
         if (dataString) {
            if (dataString.indexOf(data[i].subString) != -1)
               return data[i].identity;
         }
         else if (dataProp)
            return data[i].identity;
      }
   },
   searchVersion: function (dataString) {
      var index = dataString.indexOf(this.versionSearchString);
      if (index == -1) return;
      return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
   },
   dataBrowser: [
      {
         string: navigator.userAgent,
         subString: "Chrome",
         identity: "Chrome"
      },
      {    string: navigator.userAgent,
         subString: "OmniWeb",
         versionSearch: "OmniWeb/",
         identity: "OmniWeb"
      },
      {
         string: navigator.vendor,
         subString: "Apple",
         identity: "Safari",
         versionSearch: "Version"
      },
      {
         prop: window.opera,
         identity: "Opera",
         versionSearch: "Version"
      },
      {
         string: navigator.vendor,
         subString: "iCab",
         identity: "iCab"
      },
      {
         string: navigator.vendor,
         subString: "KDE",
         identity: "Konqueror"
      },
      {
         string: navigator.userAgent,
         subString: "Firefox",
         identity: "Firefox"
      },
      {
         string: navigator.vendor,
         subString: "Camino",
         identity: "Camino"
      },
      {      // for newer Netscapes (6+)
         string: navigator.userAgent,
         subString: "Netscape",
         identity: "Netscape"
      },
      {
         string: navigator.userAgent,
         subString: "MSIE",
         identity: "Explorer",
         versionSearch: "MSIE"
      },
      {
         string: navigator.userAgent,
         subString: "Gecko",
         identity: "Mozilla",
         versionSearch: "rv"
      },
      {       // for older Netscapes (4-)
         string: navigator.userAgent,
         subString: "Mozilla",
         identity: "Netscape",
         versionSearch: "Mozilla"
      }
   ],
   dataOS : [
      {
         string: navigator.userAgent,
         subString: "Android",
         identity: "Android"
      },
      {
         string: navigator.platform,
         subString: "Win",
         identity: "Windows"
      },
      {
         string: navigator.platform,
         subString: "Mac",
         identity: "Mac"
      },
      {
            string: navigator.userAgent,
            subString: "iPhone",
            identity: "iPhone/iPod"
       },
       {
            string: navigator.userAgent,
            subString: "iPad",
            identity: "iPad"
       },
      {
         string: navigator.platform,
         subString: "Linux",
         identity: "Linux"
      }
   ]

};
BrowserDetect.init();

$(document).ready(function()
{
   $('#MyBrowser').text('Browser: ' + BrowserDetect.browser);
   $('#MyVersion').text('Version: ' + BrowserDetect.version);
   $('#MyOS').text('OS: ' + BrowserDetect.OS + navigator.platform );
   if(BrowserDetect.OS == 'Android' || BrowserDetect.OS == 'iPhone/iPod')
   {
       $('#MyOS').html('<a href="rtsp://mm11.zradio.org/Z88-64S.sdp">Link</a>');
   }
});
