jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

/* getPageSize() by quirksmode.com
*
* @return Array Return an array with page width, height and window width, height
*/
function ___getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
};



jQuery(document).ready(function() {

	jQuery.preloadImages("/images/vb_close.gif", "/images/vb_upperleft.png", "/images/vb_upperright.png", "/images/vb_bottomleft.png", "/images/vb_bottomright.png", "/images/vb_top.png", "/images/vb_bottom.png", "/images/vb_left.png", "/images/vb_right.png");

	var browser = navigator.appName;
	var b_version = navigator.appVersion;
	var version = parseFloat(b_version);

	// --------------------- embed preloader swf -----------------//

	var flashvars2 = {};
	var params2 = {};
	var attributes2 = {};

	params2.allowScriptAccess = "always";
	attributes2.id = "videoPreloader";
	attributes2.name = "videoPreloader";
	swfobject.embedSWF("/videodata/swfs/vidPreload.swf?d=" + new Date().getMilliseconds(), "pl", "2", "2", "9.0.0", "", flashvars2, params2, attributes2);


	$(".videoAreaInner img").css({ cursor: "pointer" });
	jQuery(".videoAreaInner img").click(function() {
		var arrPageSizes = ___getPageSize();
		jQuery("#closevideo").css({ cursor: "pointer" });
		jQuery("#persistentlink").width((jQuery("#content").width() - jQuery("#urltext").width()) - 10);

		// ------------------------ Add flash with proper vars --------------//

		var flashvars = {};
		var params = {};
		var attributes = {};
		var videos = new Array();
		var titles = new Array();

		$('.benefitList ul li').each(function() {
			videos.push($(this).attr('vp'));
			titles.push($(this).text());
		});

		var videosList = videos.toString();
		var titleList = titles.toString();

		params.allowScriptAccess = "always";
		flashvars.vidPath = "/videodata/flvs/";
		flashvars.xmlPath = "/videodata/xml/";
		flashvars.vidList = videosList;
		flashvars.vidTitles = titleList;
		flashvars.vidSkinPath = "/videodata/swfs/videoplayerskin.swf";
		swfobject.embedSWF("/videodata/swfs/benefitsVideoPlayer.swf", "video", "340", "260", "9.0.0", "", flashvars, params, attributes);

		// -----------------------  Overlay stuff -----------------------//
		jQuery(".benefitvideooverlay").height(arrPageSizes[1]);
		if ((browser == "Microsoft Internet Explorer") && (version <= 6)) {
			jQuery(".benefitvideooverlay").width(arrPageSizes[0]);
		} else {
			jQuery(".benefitvideooverlay").width(arrPageSizes[0]);
			if (jQuery(document).width() > arrPageSizes[0]) {
				jQuery(".benefitvideooverlay").width(jQuery(document).width());
			}
		}

		jQuery(".benefitvideooverlay").css({
			opacity: 0.5
		});

		var intLeft = ((jQuery(window).width() - jQuery(".videoholder").width()) / 2) + jQuery(document).scrollLeft();
		var intTop = ((jQuery(window).height() - jQuery(".videoholder").height()) / 2) + jQuery(document).scrollTop();

		jQuery(".videoholder").css({
			left: intLeft + "px",
			top: intTop + "px"
		});

		jQuery(".benefitvideooverlay").fadeIn();
		jQuery(".videoholder").fadeIn();
		jQuery(window).bind('resize', f_resize);
		jQuery("#persistentlink").click(function() {
			jQuery(this).focus();
			jQuery(this).select();
		});
		jQuery("#closevideo").click(function() {
			removeOverlay();
		});
		jQuery(".benefitvideooverlay").click(function() {
			removeOverlay();
		});

		if ((browser == "Microsoft Internet Explorer") && (version <= 6)) {
			jQuery(".videoholder #bottom").css({ width: "340px" });
			jQuery(".videoholder #top").css({ width: "340px" });
			jQuery(".videoholder #right").css({ height: "332px" });
			jQuery(".videoholder #video").css("margin-bottom", "14px");
			//jQuery(".videoholder hr").css("margin-top", "10px");
			//jQuery(".videoholder hr").css("margin-bottom", "15px");
			var clear = "/images/clear.gif";
			var els = document.getElementsByTagName('*'); var ip = /\.png/i; var i = els.length; while (i-- > 0) { var el = els[i]; var es = el.style; if (el.src && el.src.match(ip) && !es.filter) { es.height = el.height; es.width = el.width; es.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + el.src + "',sizingMethod='crop')"; el.src = clear; } else { var elb = el.currentStyle.backgroundImage; if (elb.match(ip)) { var path = elb.split('"'); var rep = (el.currentStyle.backgroundRepeat == 'no-repeat') ? 'crop' : 'scale'; es.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + path[1] + "',sizingMethod='" + rep + "')"; es.height = el.clientHeight + 'px'; es.backgroundImage = 'none'; var elkids = el.getElementsByTagName('*'); if (elkids) { var j = elkids.length; if (el.currentStyle.position != "absolute") es.position = 'static'; while (j-- > 0) if (!elkids[j].style.position) elkids[j].style.position = "relative"; } } } };
		}
	});


	function f_resize() {
		var arrPageSizes = ___getPageSize();
		if ((browser == "Microsoft Internet Explorer") && (version <= 6)) {
			jQuery(".benefitvideooverlay").width(arrPageSizes[0]);
			jQuery(".benefitvideooverlay").height(arrPageSizes[1]);
		} else {
			jQuery(".benefitvideooverlay").width(arrPageSizes[0]);
			jQuery(".benefitvideooverlay").height(arrPageSizes[1]);
			if (jQuery(document).width() > arrPageSizes[0]) {
				jQuery(".benefitvideooverlay").width(jQuery(document).width());
			}
		}
	}


	function removeOverlay() {
		if (document.getElementById("video")) {
			if (document.getElementById("video").pauseplayback) {
				document.getElementById("video").pauseplayback;
			}
		}
		jQuery("#video").before("<div id='video'></div>").remove();
		jQuery(".benefitvideooverlay").fadeOut();
		jQuery(".videoholder").fadeOut(function() {
			jQuery(window).unbind('resize', f_resize);
			//jQuery(".benefitvideooverlay").remove();
			//jQuery(".videoholder").remove();
		});
	}

});
var arrFlashIDs = new Array();
arrFlashIDs.push("video");

function videoplay(strDivID){
    
}