/* Check Window Size End */
jQuery(document).ready(function(){
    /* Initialize Menu and setings */
    jQuery(".formID").validationEngine('attach', {scroll: false}); 
    function megaHoverOver(){
        jQuery(this).find(".sub").stop().fadeTo('fast', 1).show();
        (function(jQuery){ 
            jQuery.fn.calcSubWidth = function() {
                rowWidth = 0;
                jQuery(this).find("ul").each(function() {                    
                    rowWidth += jQuery(this).width(); 
                });    
            };
        })(jQuery); 
        if(jQuery(this).find(".row").length > 0){
            var biggestRow = 0;    
            jQuery(this).find(".row").each(function() {                               
                jQuery(this).calcSubWidth();
                if(rowWidth > biggestRow) { biggestRow = rowWidth; }
            });
            jQuery(this).find(".sub").css({'width' : biggestRow});
            jQuery(this).find(".row:last").css({'margin' : '0'});
        }else {
            jQuery(this).calcSubWidth();
            jQuery(this).find(".sub").css({'width' : rowWidth});
        }
    }
    function megaHoverOut(){ 
      jQuery(this).find(".sub").stop().fadeTo('fast', 0, function() {
          jQuery(this).hide(); 
      });
    }
    var config = {    
        sensitivity: 1,
        interval   : 50,
        over       : megaHoverOver, 
        timeout    : 250, 
        out        : megaHoverOut 
    };
    jQuery("ul#topnav li").hoverIntent(config);
    /* Initialize Menu */
    jQuery("ul#topnav .sub ul li:last-child").addClass("lastRound");        
    setInterval(function(){ var versions = jQuery('.textVersion:visible'); if(versions.length<2){ jQuery('.textVersion').fadeIn(800); } else { versions.eq(0).fadeOut(800); } }, 1000 );
    jQuery('.pageContents a, .footer a, .breadcrumbs a, #topnav a, .tradingBoard td.showTitle').tipsy({
        gravity : 's',
        fade    : true,
        fallback: 'Click Here'
    });
    jQuery('.headerLinks a').tipsy({
        gravity : 'n',
        fade    : true,
        fallback: 'Click Here'
    });    
    jQuery('div.scroller').load('/scripts/ajax.php?action=ticker&rand='+Math.floor(Math.random()*100),function(){
        jQuery("ul#stockScroller").liScroll({
            travelocity : 0.03,
            className   : 'scrollerStocks'
        });
        jQuery('.scrollerStocks a').tipsy({
            gravity : 's',
            fade    : true,
            fallback: 'Click Here'
        });
        jQuery('.signup td.field input,.signup td.field select').tipsy({
            gravity : 's',
            fade    : true,
            fallback: 'Enter Information Here...'
        });
        jQuery(this).css('visibility','');
        jQuery('div.scroller a').fancybox({
            'width'         : 880,
            'height'        : 300,
            'scrolling'     : 'no',
            'autoScale'     : true,
            'transitionIn'  : 'elastic',
            'transitionOut' : 'elastic',
            'type'          : 'iframe'
        });
    });
    jQuery('div.wrapperMarket').load('/scripts/ajax.php?action=market&rand='+Math.floor(Math.random()*100),function(){
        jQuery('.wrapperMarket a').tipsy({
            gravity : 's',
            fade    : true,
            fallback: 'Click Here'
        });
        jQuery('div.wrapperMarket a').fancybox({
            'width'         : 880,
            'height'        : 300,
            'scrolling'     : 'no',
            'autoScale'     : true,
            'transitionIn'  : 'elastic',
            'transitionOut' : 'elastic',
            'type'          : 'iframe',
            'opacity'       : true
        });
    });
    jQuery('#usual1').load('/scripts/ajax.php?action=watch&rand='+Math.floor(Math.random()*100),function(){
        jQuery(".usual ul").idTabs(); 
        jQuery('.watchMarket a').fancybox({
            'width'         : 800,
            'height'        : 355,
            'scrolling'     : 'no',
            'autoScale'     : false,
            'transitionIn'  : 'elastic',
            'transitionOut' : 'elastic',
            'type'          : 'iframe',
            'opacity'       : true
        });
    });
    jQuery('div.timeWrapper').load('/scripts/ajax.php?action=timing&rand='+Math.floor(Math.random()*100));
    jQuery('div.winningTrade').load('/scripts/ajax.php?action=winning&rand='+Math.floor(Math.random()*100));   
    jQuery('a.login').fancybox({
        'width'          : 1000,
        'height'         : 300,
        'scrolling'      : 'no',
        'autoScale'      : true,
        'transitionIn'   : 'elastic',
        'transitionOut'  : 'elastic',
        'type'           : 'iframe',
        'padding'        : 10,
        'margin'         : 0,
        'centerOnScroll' : true 
    });
    jQuery('.fullLogin').fancybox({
        'width'         : '97%',
        'height'        : '97%',
        'transitionIn'  : 'none',
        'transitionOut' : 'none',
        'type'          : 'iframe',
        'padding'       : 0,
        'margin'        : 0
    });
    jQuery('.homeContents a').fancybox({
        'width'         : 920,
        'height'        : '90%',
        'transitionIn'  : 'elastic',
        'transitionOut' : 'elastic',
        'type'          : 'iframe',
        'padding'       : 10,
        'margin'        : 0
    });
    jQuery('.forbes a, .yahoo a').fancybox({
        'autoScale'     : true,
        'transitionIn'  : 'elastic',
        'transitionOut' : 'elastic',
        'padding'       : 10,
        'margin'        : 0
    });
    jQuery('.whatsThis').fancybox({
        'autoScale'     : true,
        'transitionIn'  : 'elastic',
        'transitionOut' : 'elastic',
        'padding'       : 10,
        'margin'        : 0
    });
    jQuery('.cnbc a,.business a,.fox a,.bloomberg a, a.commercial').fancybox({
        'autoScale'     : true,
        'transitionIn'  : 'elastic',
        'transitionOut' : 'elastic',
        'padding'       : 10,
        'height'        : 360,
        'width'         : 480,
        'margin'        : 0,
        'type'          : 'swf'
    });
    jQuery(".tradeHistory tr, .tradingHistory tr, .tradingBoard tr").hover(
        function(){
                jQuery(this).addClass('hoverClass');
        },
        function(){
            jQuery(this).removeClass('hoverClass')
    });
    jQuery(".email-us").fancybox({
        'titleShow'     : false,
        'transitionIn'  : 'elastic',
        'height'        : 270,
        'width'         : 550,
        'transitionOut' : 'elastic',
        'easingIn'      : 'easeOutBack',
        'easingOut'     : 'easeInBack',
        'type'          : 'iframe'
    });
    jQuery(".iframe").fancybox({
        'titleShow'     : false,
        'transitionIn'  : 'elastic',
        'height'        : 600,
        'width'         : 800,
        'transitionOut' : 'elastic',
        'easingIn'      : 'easeOutBack',
        'easingOut'     : 'easeInBack',
        'type'          : 'iframe',
        'margin'        : 5
    });
    jQuery(".informUs").fancybox({
        'titleShow'     : false,   
        'transitionIn'  : 'elastic',
        'transitionOut' : 'elastic',
        'easingIn'      : 'easeOutBack',
        'easingOut'     : 'easeInBack',
        'autoScale'     : true,
        'width'         : 560,
        'height'        : 290,
        'type'          : 'iframe'
    });
});// Document Read Function Ends
/* Check Window Size */
var l = 1150;
var w = jQuery(window).width();
var a = '.headerTop .top .leftCol';
//alert(w);
if(w > 1024){ 
    jQuery(a).css('margin-left','0').css('width','50%'); ; 
}else{ 
    jQuery(a).css('margin-left','80px').css('width','42%'); 
}

/* Kick Off if Window is Resized.. */
jQuery(window).resize(function(){
    var w = jQuery(window).width();
    //alert(w);
    var a = '.headerTop .top .leftCol';
    if(w > 1150){ 
        jQuery(a).css('margin-left','0').css('width','50%'); ; 
    }else{ 
        jQuery(a).css('margin-left','80px').css('width','42%'); 
    }
});
var h = jQuery(window).height();
var d = jQuery(document).height();
var Offset = jQuery(".header").offset();
var MaxOffset = jQuery(".header").height() + Offset.top;
var a = '.header';
jQuery(window).scroll(function(){
    var set = 1;
    var p = jQuery(window).scrollTop();
    var intervalID;
    if(p == 0){ jQuery(a).removeClass('shadow').addClass('normal-shadow'); }else{ jQuery(a).addClass('shadow').removeClass('normal-shadow'); }
});
