/** 
* ======================================================
* $Workfile:   global.js  $
* $Revision:   1.14  $
* $Date:   Jun 22 2010 13:19:56  $
* $Author:   goddarmx  $
* $Archive:   //legal.regn.net/npv/Dev-Archives/Development_Area/archives/LargeLaw/PageDesigner/Phoenix/FrontEnd/Code/LexisNexis/Website/Assets/js/global.js-arc  $
* ======================================================
* Change History:
* 1.00 initial revision
* 1.01 Add noConflict (jQuery) to the $()function factory due to other js libraries being used and causing conflicts.
**/       

/*	<><><><><><>
//	Global functions :: all functions are shared across all designs and templates
//	These functions are used with jQuery core
<><><><><><>*/ 
//  create resuable short name for jQuery no conflict
var $j = jQuery.noConflict();
   

function addBookmark() {
		// browser checking and branching, since not all browsers allow bookmark the exact same way.
		// set the rel attribute for the link to sidebar so that Opera will pick this up.  This may not be necessary for new versions though -- test out later
		if(window.opera){
			if($j('div#bookmark a').attr('rel') != "") {
				$j('div#bookmark a').attr('rel','sidebar');
			}
		}
		
		/* lets create the event handler and assigned to the anchor and once the event is triggered go through the if and check to see which browser is used and us the appropriate add bookmark syntax */
		$j('div#bookmark a').click(function(event) {
			event.preventDefault(); // this prevents the default behavior of the anchor link to follow the href value
			var url = this.href; // this assigns the current page's href value to the var 'url'
			var title = this.title; // this assigns the current page's title value to the var 'title'
			
			// now lets check to see which browser the user is using!
			if(window.sidebar) {
				/* - ////	FIREFOX	\\\\ - */
				window.sidebar.addPanel(title, url,"");
			} else if (window.external){
				/* - //// IE	\\\\ - */
				window.external.AddFavorite(url, title);
			} else {
				/* - //// Opera Safari and all other browsers that do not support javascript bookmark scripts	\\\\ - */
				alert('Please use "Ctrl-D (PC Win) or Cmd-D (Mac OS)" to bookmark this page.');
			}
		});
/*	m()m	*/
}

function showLanguage(obj) {
	//  this shows and hides the language selector
	$j('a#showLanguages').attr('href','#');
	$j('a#showLanguages').click(function(event) {
		$j('ul.ulLanguages ul').toggleClass('show'); // basically adds the class 'show' which is set to display: block; in global.css
		if($j('#closeLink').length == 0)
		    $j('<li id="closeLink" class="last"><a href="#" title="Close Language Menu">Close</a></li>').appendTo('ul.ulLanguages ul'); // add a close link to the list since this is a dynamic list built :: this would be better if it could be handled by backend when list is built dynamically
		
		/*	NOTE :: attached the event listener to the close link within the event listener for the show link :: have to do this because currently the close link does NOT exist so when page load, jQuery cannot attached the event listener to it.  IF we change the behavior of how the close anchor is attached to the XHTML via backend technology then this event listener will need to be on it's own
		*/
		$j('li#closeLink a').click(function(event) {
			$j('ul.ulLanguages ul').removeClass('show');	
			$j('li#closeLink').remove();
			return false;
		});
		
		return false;
	});
/*	m()m	*/
}

/*function updateNavZIndex() {
	$j('ul#nav > li').each(
		function(i) {
			$j(this).css('z-index',$j('ul#nav > li').length - i);
		}
	);
}*/

function fixIE6DropDown(el) {
	$j(el).hover(function(){$j(this).addClass('hover');},function(){$j(this).removeClass('hover');});
}


/* Resizing the video */
function resizeVideo() {
	$j('object').css({width:'220px',height:'178px'});
	$j('embed').css({width:'220px',height:'178px'});
}

/* Show sitecore inline editbar */
function showInlineEditbar(){
    if($j('.scWebEditInput'))
    {
        $j('.scWebEditInput').mouseover(function(event) {
             var parentDiv = $j(this).parents('div');
             var flag = true;
             
             parentDiv.each(function(index) { 
                if($j(this).attr('id') == 'middleArea')
                {
                    flag = false;
                }
             });
             
             if(!flag)
                return false;
             
             parentDiv.each(function(index) { 
                  var cssOverflow = $j(this).css('overflow');
                  if(cssOverflow == 'hidden')
                  {
                      $j(this).css('overflow','visible');
                      $j(this).mouseout(function(event) {
                            $j(this).css('overflow','hidden');
                      });
                      return false;
                  }
             });
        });
        
        $j('.scWebEditFrameButtons').mouseover(function(event) {
             var parentDiv = $j(this).parents('div');
             var flag = true;
             
             parentDiv.each(function(index) { 
                if($j(this).attr('id') == 'middleArea')
                {
                    flag = false;
                }
             });
             
             if(!flag)
                return false;
                
             parentDiv.each(function(index) { 
                  var cssOverflow = $j(this).css('overflow');
                  if(cssOverflow == 'hidden')
                  {
                      $j(this).css('overflow','visible');
                      $j(this).mouseout(function(event) {
                            $j(this).css('overflow','hidden');
                      });
                      return false;
                  }
             });
        });
    }
}


$j(document).ready(function () {
    showInlineEditbar();
    resizeVideo();
	addBookmark();
	showLanguage();
	$j('#podWrap .pod:odd').addClass('podAlt');
	//updateNavZIndex();
});
/*	m()m	*/
