// JavaScript Document
// Blue J interactive 10.13.11 add vidoe ot home page

$(document).ready(function() {
						   
var homepage = $('#slidevideo').length;
var whyus = $('#personalstory').length;
var vidimage = 'slideshow_launch.jpg';
var vidimageh = 323;
var vidimagew = 637;
var isiPad = navigator.userAgent.match(/iPad/i) != null;
var isiPhone = navigator.userAgent.match(/iPhone/i) != null;

if(whyus) {
	vidimage = 'personalstory.png';
	vidimageh = 320;
	vidimagew = 693;
};

function preload(arrayOfImages) {
    $(arrayOfImages).each(function(){
        $('<img/>')[0].src = this;
    });
}

// Usage:

preload([
    'nav_images/nav_01.jpg',
    'nav_images/nav_02.jpg',
    'nav_images/nav_03.jpg',
	'nav_images/nav_04.jpg',
	'nav_images/nav_05.jpg',
	'nav_images/nav_06.jpg',
	'nav_images/nav_07.jpg',
	
	'nav_images/overs_01.jpg',
	'nav_images/overs_02.jpg',
	'nav_images/overs_03.jpg',
	'nav_images/overs_04.jpg',
	'nav_images/overs_05.jpg',
	'nav_images/overs_06.jpg',
	'nav_images/overs_07.jpg',
]);

if(homepage){

preload([
    'base-nav_images/base-nav_4c_01.jpg',
	'base-nav_images/base-nav_4c_02.jpg',
	'base-nav_images/base-nav_4c_03.jpg',
	'base-nav_images/base-nav_4c_04.jpg',
	'base-nav_images/base-nav_4c_05.jpg',
	'base-nav_images/base-nav_4c_06.jpg',
	'base-nav_images/base-nav_4c_07.jpg',
	
	'base-nav_images/base-nav_ro_01.jpg',
	'base-nav_images/base-nav_ro_02.jpg',
	'base-nav_images/base-nav_ro_03.jpg',
	'base-nav_images/base-nav_ro_04.jpg',
	'base-nav_images/base-nav_ro_05.jpg',
	'base-nav_images/base-nav_ro_06.jpg',
	'base-nav_images/base-nav_ro_07.jpg',
	
	'base-nav_images/popup_01.jpg',
	'base-nav_images/popup_02.jpg',
	'base-nav_images/popup_03.jpg',
	'base-nav_images/popup_04.jpg',
	'base-nav_images/popup_05.jpg',
	'base-nav_images/popup_06.jpg',
	'base-nav_images/popup_07.jpg',
]);

}

if (homepage || whyus) {
	if(PluginDetect.getVersion('Flash')){
		$('#slidevideo').replaceWith('<a href="greg_hurley.flv" rel="shadowbox;player=flv;height=400;width=710"><img src="images/'+vidimage+'"  class="replaceimg" width="'+vidimagew+'" height="'+vidimageh+'" border="0" id="r12"></a>');
		
	} else if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))){
		$('#slidevideo').replaceWith('<a href="greg_hurley_iphone.mp4" rel="shadowbox;height=400;width=710"><img src="images/'+vidimage+'"  class="replaceimg" width="'+vidimagew+'" height="'+vidimageh+'" border="0" id="r12"></a>');
	} else {
		$('#slidevideo').replaceWith('<a href="greg_hurley_iphone.mp4" rel="shadowbox;height=400;width=710"><img src="images/'+vidimage+'"  class="replaceimg" width="'+vidimagew+'" height="'+vidimageh+'" border="0" id="r12"></a>');
	};


	
	

if(homepage) {

	$('#s2').cycle({ 
		fx:     'fade',  
		timeout: 10000,
		next:   '#next2', 
		prev:   '#prev2'
	});

	$('#ri1').hover(function () {$('#s2').cycle('pause')}, function(){$('#s2').cycle('next'); $('#s2').cycle('resume')});
	
}

//////////////////////////////////////////////////////////////////////// JWSTATE ////////////////////////////////////////////////////////////////////////
        
		   
           function onShOpen() {
              // console.log('Shadowbox onOpen - Shadowbox has Started!');
			   if(homepage) {$('#s2').cycle('pause');};
			   // ie scroll issue
if ($.browser.msie) {

$('#sb-overlay').css('height', $.getDocHeight());

}


if(isiPad || isiPhone){
	$('#sb-overlay').css('height', $(document).height());
	var ww = $(window).width +50;
	$('#sb-overlay').css('width', ww);

}
				// end ie issuue
			   $('#sb-info').prepend('<div id="vidlinks"><a href="http://www.linkedin.com/company/hurley-wealth-management-group"><img src="images/li.png" alt="Connect With Us on LinkedIn" width="16" height="16" border="0" /> <span class="linkpos">LinkedIn</span></a><span class="linkpos"> | </span><a href="contact.php"><span class="linkpos">Contact Us</span></a></div>');
           }

           function onShFinish() {
             if ($.browser.msie) {
				currentstyle = $('#sb-wrapper').attr('style');
				var offset = $(window).scrollTop() + ($(window).height()/2) - 200;
				$('#sb-wrapper').attr('style',currentstyle + "; top:"+offset+"px");
			}
			
			if(isiPad || isiPhone){
				currentstyle = $('#sb-wrapper').attr('style');
				var offset = $(window).scrollTop() + ($(window).height()/2) - 200;
				$('#sb-wrapper').attr('style',currentstyle + "; top:"+offset+"px");

			}
           }

           function onShChange() {
             //  console.log('Shadowbox onChange - Shadowbox has Changed!');
           }

           function onShClose() {
            //   console.log('Shadowbox onClose - Shadowbox has Closed!');
			 	// ie scroll issue
			   $('#vidlinks').remove(); 
			   if(homepage) {$('#s2').cycle('next'); $('#s2').cycle('resume');};
           }
		   
		   Shadowbox.init({
			   players:    ['flv', 'mp4'],
               scrolling: "no",
			   handleOversize: "resize",
               troubleElements: "select",
               animate: true,
               animateSequence: 'sync',                          // Certain settings like sync are default, so no need to declare them unless something different is used.
               resizeDuration: 0.70,
               overlayOpacity: 0.80,                             // 0.80 was default
               fadeDuration: 0.35,
               continuous: true,
               displayNav: true,
               onOpen: onShOpen,
               onFinish: onShFinish,
               onChange: onShChange,
               onClose: onShClose,
               flashVars: {                                      
                   'wmode': 'transparent',
                   'controlbar.position': 'bottom',              // Values of bottom, top, and over apply. Mode 'over' will free up the otherwise used space originally allocated for controlbar 'top' or 'bottom'. Since the free space exists with mode 'over', it's best to have a  jwControllerHeight  at 0 pixles (See 'shadowbox.js' comment above). Side Note: Expect to see a custom New OPTION mod to allow  jwControllerHeight  on per link basis.
                   'controlbar.margin': '0',                     // Undocumented Feature to float the Control Bar Higher or lower than the default position of 10. Must be using Controlbar Mode OVER or Full Screen Mode to see this change. When set to 0 it simulates Controlbar 'bottom' with the exception it covers the video content on Idle state but fades away during playback/mouse out.
                   'controlbar.idlehide': 'false'
               },
               flashParams: {
                   'id': 'ShadowboxID',                          // This 'id' will be shown when JW Player Listener has player activity in Shadowbox.
                   'name': 'ShadowboxID',                        // Both 'id' and 'name' are presented here for visual confirmation. When these items are not provided the value is 'null'
                   'allowscriptaccess': 'SameDomain',
                   'allowfullscreen': 'true'
               }

           });

//////////////////////////////////////////////////////////////////////// JWSTATE ////////////////////////////////////////////////////////////////////////
if(homepage) {

	 

	
		// Base nave rollover - fix for dynamic script - look into issue 2/9 
	$('#basenav1').hover(
	  function () {
		$('#s2').cycle('pause');
		$('#slidenav').hide();
		$(this).attr('src', 'base-nav_images/base-nav_ro_01.jpg');
		$('#rolls').html('<img src="base-nav_images/popup_01.jpg" width="637" height="323">');
	  }, 
	  function () {
		$(this).attr('src', 'base-nav_images/base-nav_4c_01.jpg');
		$('#slidenav').show();
		$('#rolls').html('');
		$('#s2').cycle('resume'); 
	  }
	);
	
		// Base nave rollover - fix for dynamic script - look into issue 2/9 
	$('#basenav2').hover(
	  function () {
		$('#s2').cycle('pause');
		$('#slidenav').hide();
		$(this).attr('src', 'base-nav_images/base-nav_ro_02.jpg');
		$('#rolls').html('<img src="base-nav_images/popup_02.jpg" width="637" height="323">');
	  }, 
	  function () {
		$(this).attr('src', 'base-nav_images/base-nav_4c_02.jpg');
		$('#slidenav').show();
		$('#rolls').html('');
		$('#s2').cycle('resume'); 
	  }
	);
	
		// Base nave rollover - fix for dynamic script - look into issue 2/9 
	$('#basenav3').hover(
	  function () {
		$('#s2').cycle('pause');
		$('#slidenav').hide();
		$(this).attr('src', 'base-nav_images/base-nav_ro_03.jpg');
		$('#rolls').html('<img src="base-nav_images/popup_03.jpg" width="637" height="323">');
	  }, 
	  function () {
		$(this).attr('src', 'base-nav_images/base-nav_4c_03.jpg');
		$('#slidenav').show();
		$('#rolls').html('');
		$('#s2').cycle('resume'); 
	  }
	);
	
		// Base nave rollover - fix for dynamic script - look into issue 2/9 
	$('#basenav4').hover(
	  function () {
		$('#s2').cycle('pause');
		$('#slidenav').hide();
		$(this).attr('src', 'base-nav_images/base-nav_ro_04.jpg');
		$('#rolls').html('<img src="base-nav_images/popup_04.jpg" width="637" height="323">');
	  }, 
	  function () {
		$(this).attr('src', 'base-nav_images/base-nav_4c_04.jpg');
		$('#slidenav').show();
		$('#rolls').html('');
		$('#s2').cycle('resume'); 
	  }
	);
	
		// Base nave rollover - fix for dynamic script - look into issue 2/9 
	$('#basenav5').hover(
	  function () {
		$('#s2').cycle('pause');
		$('#slidenav').hide();
		$(this).attr('src', 'base-nav_images/base-nav_ro_05.jpg');
		$('#rolls').html('<img src="base-nav_images/popup_05.jpg" width="637" height="323">');
	  }, 
	  function () {
		$(this).attr('src', 'base-nav_images/base-nav_4c_05.jpg');
		$('#slidenav').show();
		$('#rolls').html('');
		$('#s2').cycle('resume'); 
	  }
	);
	
		// Base nave rollover - fix for dynamic script - look into issue 2/9 
	$('#basenav6').hover(
	  function () {
		$('#s2').cycle('pause');
		$('#slidenav').hide();
		$(this).attr('src', 'base-nav_images/base-nav_ro_06.jpg');
		$('#rolls').html('<img src="base-nav_images/popup_06.jpg" width="637" height="323">');
	  }, 
	  function () {
		$(this).attr('src', 'base-nav_images/base-nav_4c_06.jpg');
		$('#slidenav').show();
		$('#rolls').html('');
		$('#s2').cycle('resume'); 
	  }
	);
	
		// Base nave rollover - fix for dynamic script - look into issue 2/9 
	$('#basenav7').hover(
	  function () {
		$('#s2').cycle('pause');
		$('#slidenav').hide();
		$(this).attr('src', 'base-nav_images/base-nav_ro_07.jpg');
		$('#rolls').html('<img src="base-nav_images/popup_07.jpg" width="637" height="323">');
	  }, 
	  function () {
		$(this).attr('src', 'base-nav_images/base-nav_4c_07.jpg');
		$('#slidenav').show();
		$('#rolls').html('');
		$('#s2').cycle('resume'); 
	  }
	);
	
};
	//var cache = [];
	  // Arguments are image paths relative to the current page.
	 // $.preLoadImages = function() {
	//	var args_len = arguments.length;
	//	for (var i = args_len; i--;) {
	//	  var cacheImage = document.createElement('img');
	//	  cacheImage.src = arguments[i];
		//  cache.push(cacheImage);
		//}
	//  }
	
	
	//var i=1;
	//for (i=1;i<=7;i++)
	//{
	//if(homepage) {$.preLoadImages("/base-nav_images/popup_0"+i+".jpg", "/base-nav_images/popup_0"+i+".jpg");};
	//if(homepage) {$.preLoadImages("/base-nav_images/base-nav_ro_0"+i+".jpg", "/base-nav_images/base-nav_ro_0"+i+".jpg");};
	//$.preLoadImages("/nav_images/overs_0"+i+".jpg", "/nav_images/overs_0"+i+".jpg");
	//}

}; // end if slide exists


$.getDocHeight = function(){
     var D = document;
     return Math.max(Math.max(D.body.scrollHeight,    D.documentElement.scrollHeight), Math.max(D.body.offsetHeight, D.documentElement.offsetHeight), Math.max(D.body.clientHeight, D.documentElement.clientHeight));
};





$('#hwlogo').click(function() {
  window.location = "index.html";
});



 
$('#Image1').hover(
  function () {
	$(this).attr('src', 'nav_images/overs_01.jpg');
  }, 
  function () {
	$(this).attr('src', 'nav_images/nav_01.jpg');
  }
);

$('#Image2').hover(
  function () {
	$(this).attr('src', 'nav_images/overs_02.jpg');
  }, 
  function () {
	$(this).attr('src', 'nav_images/nav_02.jpg');
  }
);

$('#Image3').hover(
  function () {
	$(this).attr('src', 'nav_images/overs_03.jpg');
  }, 
  function () {
	$(this).attr('src', 'nav_images/nav_03.jpg');
  }
);

$('#Image4').hover(
  function () {
	$(this).attr('src', 'nav_images/overs_04.jpg');
  }, 
  function () {
	$(this).attr('src', 'nav_images/nav_04.jpg');
  }
);

$('#Image5').hover(
  function () {
	$(this).attr('src', 'nav_images/overs_05.jpg');
  }, 
  function () {
	$(this).attr('src', 'nav_images/nav_05.jpg');
  }
);

$('#Image6').hover(
  function () {
	$(this).attr('src', 'nav_images/overs_06.jpg');
  }, 
  function () {
	$(this).attr('src', 'nav_images/nav_06.jpg');
  }
);

$('#Image7').hover(
  function () {
	$(this).attr('src', 'nav_images/overs_07.jpg');
  }, 
  function () {
	$(this).attr('src', 'nav_images/nav_07.jpg');
  }
);

$('#Image8').hover(
  function () {
	$(this).attr('src', 'nav_images/overs_08.jpg');
  }, 
  function () {
	$(this).attr('src', 'nav_images/nav_08.jpg');
  }
);
 



// end doc ready		
});

   
