_ie6 = false;

var SHARETHIS = null;
var fgData = null;
var keyword = null;
var key = null;
var flowplayerobj= null;
var obj = new Object();
var imageObject = null;
var videoObject  =null;
var selectedIndex = null;

String.prototype.trunc =     function(n,useWordBoundary){
								 var toLong = this.length>n,
									 s_ = toLong ? this.substr(0,n-1) : this;
								 s_ = useWordBoundary && toLong ? s_.substr(0,s_.lastIndexOf(' ')) : s_;
								 return  toLong ? s_ +'...' : s_;
							  };
						 

jQuery(document).ready(function(){
		
		selectedIndex = getUrlParameter('selectedIndex') == '' ? 1 : parseInt(getUrlParameter('selectedIndex'));

		loadInit();

		if($('#flash-media').length)
			loadFlash();
     	                 $('.jquery-selectbox-list span.item-0').text('All');
		$('#category-image-select option:selected').text('All');
		$('#category-video-select option:selected').text('All');
	});

// function triggered on load
function loadInit(){
			if($.browser.msie)
				if($.browser.version == "6.0")
				{
					$('#masthead #sitesul li').mouseover(function(){
					
						$('> ul',$(this)).show();
                                                                                                $('.last',$(this)).css({'margin-top':'-8px'});  						
					});
					$('#masthead #sitesul li').mouseout(function(){
					
						$('> ul',$(this)).hide();
						
					});
				
						
			}
			//creates an overlay for TIBCO fast facts
			$('#fast-fact-btn').attr('rel','#overlay-content');
			$('#container').append('<div id="overlay-content" class="overlay"></div>');
			if(('#fast-fact button').length)
				{
					var html = $('#fast-fact-content').html();
					$('#overlay-content').html(html);
					var api = $("button[rel]").overlay({
						expose:{color:'#000',closeSpeed:0,loadSpeed:0}, speed:0, onBeforeLoad: beforeLoad, onClose:onClose});
					
				}
		
			
			//creates rounded corners for all divs having classe rounded
			jQuery('div.rounded').wrap('<div class="rounded-border"></div>');
		   jQuery('div.rounded').corner("round 8px").parent().css('padding', '2px').corner("round 10px");
			
			//adding a border to the right of every alternate element
			$('#follow-us ul li:even').css({'border-right':'1px solid #e2e3e5'});
			
			//converts image select box into customized selectbox
			if($("#category-image-select").length)	{
				$("#category-image-select").selectbox();
				$("#category-image-select").selectbox().bind('change', function(){
						var t = $(this).val();
						var str = $('.value-'+t).text();
						if(str=='All' || str=='Filter here')
							str = null;
						
							obj.xml = imageXml;
							obj.key = str;
							window.setTimeout('convertToXml(obj)', 1000);
				});
			}
			//converts video select box into customized selectbox
			if($("#category-video-select").length){
				$("#category-video-select").selectbox();
				$("#category-video-select").selectbox().bind('change', function(){
						var t = $(this).val();
						var str = $('.value-'+t).text();
						if(str=='All' || str=='Filter here')
							str = null;
					
							obj.xml =videoXml;
							obj.key = str;
							window.setTimeout('convertToXml(obj)', 1000);
						
				});
			}
			//customized adding styles to the select box
			if($('.jquery-selectbox').length)			{	
				$('.jquery-selectbox, .jquery-selectbox-list').css('width','428px');
				var lt = $('.jquery-selectbox-item').length;
				$('.jquery-selectbox-list').css('height',lt*20+'px');
			}
			
			 //converts div with class highlights-scrollable into a highlight box
			if($('.highlights-scrollable').length)	{
				var api = $('.highlights-scrollable').scrollable({size:1,speed:0,clickable:false,keyboard:false,circular:true}).autoscroll(10000).navigator({
					navi: '.controls',
					naviItem: 'a',
					api:true
				});
				api.onBeforeSeek(function(){
					if(!$('.highlights-scrollable ul li div h3').is(':animated'))
					 	$('.highlights-scrollable ul li div h3').fadeOut(0);
					if(!$('.highlights-scrollable ul li div p').is(':animated'))
					 	$('.highlights-scrollable ul li div p').fadeOut(0);
				});
				api.onSeek(function(){
					if(!$('.highlights-scrollable ul li div h3').is(':animated'))
						$('.highlights-scrollable ul li div h3').fadeIn(1000);
					if(!$('.highlights-scrollable ul li div p').is(':animated'))
						$('.highlights-scrollable ul li div p').fadeIn(1000);
				});
				
			 }
			 
			 //
			 $('#nav-features ul#nav-menu li.top').mouseover(function(event){
				$(this).css({'background-position':'-1px -33px'});	
			 })
			 .mouseout(function(event) {
				$(this).css({'background-position':'-1px 0px'});
    		});
			 $('#nav-features ul#nav-menu li.bottom').mouseover(function(event){
				$(this).css({'background-position':'-1px -34px'});	
				if($.browser.msie)
						if($.browser.version == "6.0")
						{
							$(this).css({'background-position':'-1px -33px','margin-top':'-2px'});	
							//$(this).find('a').css({'padding-top':'9px'});
						}
			 }) 
			 .mouseout(function(event) {
				$(this).css({'background-position':'0 0'});
				if($.browser.msie)
						if($.browser.version == "6.0")
						{
							$(this).css({'background-position':'0 1px'});
						}
    		});

		 $('.tip').cluetip({
				  splitTitle: '|', 
				  arrows: true, 
				  dropShadow: false, 
				  cluetipClass: 'jtip'}
				);
		if($.browser.msie)
			if($.browser.version == "6.0")
				{		
					
						$('#image-filter-select').css({'position':'static'});
						$('#video-filter-select').css({'position':'static'});
						$('.jquery-selectbox').css({'position':'absolute','float':'left'});
				} 
}
function beforeLoad(){ 
if($('.stclose').length)
	$('.stclose').trigger('click');
if($('#newsroom-search-results').length)	
	$('#newsroom-search-results').hide();
}
function onClose(){
if($('#newsroom-search-results').length)	
	showSearch();
}

function showSearch(){
	$('#newsroom-search-results').show();
}

function convertToXml(obj){
	data = obj.xml;
	source = obj.key;
		if (window.DOMParser)
			  {
				  parser=new DOMParser();
				  xmlDoc=parser.parseFromString(data,"text/xml");
			  }
			else // Internet Explorer
			  {
				  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
				  xmlDoc.async="false";
				  xmlDoc.loadXML(data);
			  }
		  
		  if(source=="fg")//featured-gallery
		  {
				fgData = xmlDoc;
				showFeaturedGallery(keyword);
			}
		  else                         // filter-search
		   showFeaturedGallery(source);
		
}

function newWin(url){
	window.open(url);
}

function showFeaturedGallery(key){	
	
	if($('#image-carousel').length)
	{	
		setFeaturedImageGallery(key);
	}
	else if($('#video-carousel').length)
	{
		setFeaturedVideoGallery(key);
	}

}//end of func
function setFeaturedImageGallery(key){
		var i=1;
		var flag =false;
		if(!imageObject)
		{
			$('.wide-scrollable').prepend('<ul class="items"></ul>');
			 jQuery('.wide-scrollable').scrollable({size:4}).navigator({ navi: '.gallery-controls', idPrefix : 'image', api : true });
			 imageObject = jQuery('.wide-scrollable').scrollable();
		}
		else
		{
                                   imageObject.begin();
		   imageObject.getItems().remove();
			 $('#image-carousel a.left').attr('class','left prevPage browse disabled');
			 $('#image-carousel a.right').attr('class','right nextPage browse disabled');
			 $('.wide-scrollable ul').css({'left':'0'});
			 imageObject.reload().begin();
		}
		
		
		if(key==null){	
			$('gallery > item', fgData).each(function(){	
				flag = true;
				var thumbUrl = $('>thumbnail', $(this)).text();
				var mainImgUrl = $('>mainimage', $(this)).text();
				var title = $('>title', $(this)).text();
				var tags = $('>keywords', $(this)).text();
				var lowResUrl = $('>lowres',$(this)).text();
				var highResUrl = $('>highres',$(this)).text();
				
			imageObject.getItemWrap().append('<li>'
					+thumbUrl
					+'<h4 id="title_'+i+'">'+title.trunc(55,true)+'</h4>'
					+'<p id="fulltitle_'+i+'" style="display:none;">'+title+'</p>'
					+'<p id="mainimage_'+i+'" style="display:none; ">'+mainImgUrl+'</p>'
					+'<p id="tag_'+i+'" style="display:none; ">'+tags+'</p>'
					+'<p id="lowres_'+i+'" style="display:none; ">'+lowResUrl+'</p>'
					+'<p id="highres_'+i+'" style="display:none; ">'+highResUrl+'</p>'
					+'</li>');
						
				$('.wide-scrollable ul li:eq('+(i-1)+')').children('img:eq('+0+')').attr('id','img_'+i);
				$('.wide-scrollable ul li:eq('+(i-1)+')').children('img:eq('+0+')').bind('click', function(){
					switchImgDetails($(this).attr('id').substring(4));
				});
				$('.wide-scrollable ul li:eq('+(i-1)+')').children('img:eq('+0+')').attr('width','91');
				$('.wide-scrollable ul li:eq('+(i-1)+')').children('img:eq('+0+')').attr('height','75');
				createShareThis(i);
				i++;
			});
			
				if($('#main-image').length)		 
				{
					switchImgDetails(selectedIndex);
				}

		}
	
		else
		{	
			
			$('gallery > item', fgData).each(function(){	
					var cat = $(this).find('category').text();
					var catArr = cat.split(",");
					var j;
					
				for(j=0; j<catArr.length; j++)
				{
					if(catArr[j]==key){
							flag=true;
							var thumbUrl = $('>thumbnail', $(this)).text();
							var mainImgUrl = $('>mainimage', $(this)).text();
							var title = $('>title', $(this)).text();
							var tags = $('>keywords', $(this)).text();
							var lowResUrl = $('>lowres',$(this)).text();
							var highResUrl = $('>highres',$(this)).text();
						
						imageObject.getItemWrap().append('<li>'
								+thumbUrl
								+'<h4 id="title_'+i+'">'+title.trunc(55,true)+'</h4>'
								+'<p id="fulltitle_'+i+'" style="display:none;">'+title+'</p>'
								+'<p id="mainimage_'+i+'" style="display:none; ">'+mainImgUrl+'</p>'
								+'<p id="tag_'+i+'" style="display:none; ">'+tags+'</p>'
								+'<p id="lowres_'+i+'" style="display:none; ">'+lowResUrl+'</p>'
								+'<p id="highres_'+i+'" style="display:none; ">'+highResUrl+'</p>'
								+'</li>');
							
							$('.wide-scrollable ul li:eq('+(i-1)+')').children('img:eq('+0+')').attr('id','img_'+i);
							$('.wide-scrollable ul li:eq('+(i-1)+')').children('img:eq('+0+')').bind('click', function(){
								switchImgDetails($(this).attr('id').substring(4));
							});
							$('.wide-scrollable ul li:eq('+(i-1)+')').children('img:eq('+0+')').attr('width','91');
							$('.wide-scrollable ul li:eq('+(i-1)+')').children('img:eq('+0+')').attr('height','75');
								createShareThis(i);
							i++;
						}
						
				}
			
				});
			
		if(!flag)
				imageObject.getItemWrap().append('<li class="noresults">No Results Found</li>');
		else if($('#main-image').length)		 
			{
				switchImgDetails(1);
			}
		
		}//end key null
		
		imageObject.reload();		
		if(imageObject.getPageAmount() > 1) {  
			$('#image-carousel a.right').attr('class','right nextPage browse'); 
		}
		var count =$('#image-carousel ul li').length;
		if(count<5){ $('#image-carousel div.gallery-controls a').css('display','none'); }
		var w = 25 * Math.ceil(count/4);
		$('.gallery-controls').css({'width':w+'px'});
}

function switchImgDetails(id){


	$('#tools ul li:eq(0)').children('span').attr('class','icon hidden');
	$('#tools ul li:eq(0)').children('#share-'+id).attr('class','icon');
		if($('#main-image img').length)
			$('#main-image img').remove();
		$('#main-image').append('<img src="" alt=""/>');
		$('#main-image img').attr('src',$('#mainimage_'+id).text());
		$('#image-details div#title h3').html($('#fulltitle_'+id).text());
		$('#image-details div#tag p').html($('#tag_'+id).text());
		$('#download-low-res a').attr('href',$('#lowres_'+id).text());
		$('#download-low-res a').unbind().bind('click',function(){
			BlankWin($('#lowres_'+id).text());
			return false;
		});
		$('#download-high-res a').attr('href',$('#highres_'+id).text());
		$('#download-high-res a').unbind().bind('click',function(){
			BlankWin($('#highres_'+id).text());
			return false;
		});
			var url  = "";                                           

				if(($('#mainimage_'+id).text()).substr(0,7) !='http://') 
				{
				url = '"http://'+ window.location.hostname +'/'+$('#mainimage_'+id).text()+'"';
				}
				else
				{
				url = '"'+$('#mainimage_'+id).text()+'"';
				}

				var title = '"'+$('#fulltitle_'+id).text()+'"';
		
		if(!($.browser.msie && ($.browser.version == "6.0")))
			addthis.button('#share-'+id, {}, { url: url, title: title });

}
function setFeaturedVideoGallery(key){
		var i=1;
		var flag =false;
	if(!videoObject)
		{
			$('.wide-scrollable').prepend('<ul class="items"></ul>');
			 jQuery('.wide-scrollable').scrollable({size:4}).navigator({ navi: '.gallery-controls', idPrefix : 'image', api : true });
			 videoObject = jQuery('.wide-scrollable').scrollable();
		}
		else
		{
            videoObject.begin();
		   videoObject.getItems().remove();
			 $('#video-carousel a.left').attr('class','left prevPage browse disabled');
			 $('#video-carousel a.right').attr('class','right nextPage browse disabled');
			 $('.wide-scrollable ul').css({'left':'0'});
			 videoObject.reload().begin();
		}
	
		if(key==null){	
			
			$('gallery > item', fgData).each(function(){	
				flag = true;
				var thumbUrl = $('>thumbnail', $(this)).text();
				var mainVideoSnapshot = $('>snapshot', $(this)).text();
				var mainVideoUrl = $('>video', $(this)).text();
				var title = $('>title', $(this)).text();
				var tags = $('>keywords', $(this)).text();
				var duration = $('>duration',$(this)).text();
				var type = $('>videotype',$(this)).text();
				
			videoObject.getItemWrap().append('<li>'
					+thumbUrl
					+'<h4 id="title_'+i+'">'+title.trunc(55,true)+'</h4>'
					+'<p id="fulltitle_'+i+'" style="display:none;">'+title+'</p>'
					+'<p id="duration_'+i+'" class="duration">'+duration+'</p>'
					+'<p id="mainvideo_'+i+'" class="hidden">'+mainVideoUrl+'</p>'
					+'<p id="mainvideo-snapshot'+i+'" class="hidden">'+mainVideoSnapshot+'</p>'
					+'<p id="tag_'+i+'" class="hidden">'+tags+'</p>'
					+'<p id="videotype_'+i+'" class="hidden">'+type+'</p>'
					+'</li>');
						createShareThis(i);
				$('.wide-scrollable ul li:eq('+(i-1)+')').children('img:eq('+0+')').attr('id','vid_'+i);
				$('.wide-scrollable ul li:eq('+(i-1)+')').children('img:eq('+0+')').bind('click', function(){
					switchVideoDetails($(this).attr('id').substring(4));
				});
				$('.wide-scrollable ul li:eq('+(i-1)+')').children('img:eq('+0+')').attr('width','91');
				$('.wide-scrollable ul li:eq('+(i-1)+')').children('img:eq('+0+')').attr('height','75');
				i++;
			});
			if($('#main-video').length)		 
				switchVideoDetails(selectedIndex);
		}
		else
		{	
			flag = false;
			$('gallery > item', fgData).each(function(){	
					var cat = $('>category',$(this)).text();
					if(cat==key)
					{
							flag=true;
							var thumbUrl = $('>thumbnail', $(this)).text();
							var mainVideoSnapshot = $('>snapshot', $(this)).text();
							var mainVideoUrl = $('>video', $(this)).text();
							var title = $('>title', $(this)).text();
							var tags = $('>keywords', $(this)).text();
							var duration = $('>duration',$(this)).text();
							var type = $('>videotype',$(this)).text();
						
					videoObject.getItemWrap().append('<li>'
								+thumbUrl
								+'<h4 id="title_'+i+'">'+title.trunc(55,true)+'</h4>'
								+'<p id="fulltitle_'+i+'" style="display:none;">'+title+'</p>'
								+'<p id="duration_'+i+'" class="duration">'+duration+'</p>'
								+'<p id="mainvideo_'+i+'" class="hidden">'+mainVideoUrl+'</p>'
								+'<p id="mainvideo-snapshot'+i+'" class="hidden">'+mainVideoSnapshot+'</p>'
								+'<p id="tag_'+i+'" class="hidden">'+tags+'</p>'
								+'<p id="videotype_'+i+'" class="hidden">'+type+'</p>'
								+'</li>');
								createShareThis(i);			
							$('.wide-scrollable ul li:eq('+(i-1)+')').children('img:eq('+0+')').attr('id','vid_'+i);
							$('.wide-scrollable ul li:eq('+(i-1)+')').children('img:eq('+0+')').bind('click', function(){
								switchVideoDetails($(this).attr('id').substring(4));
							});
							$('.wide-scrollable ul li:eq('+(i-1)+')').children('img:eq('+0+')').attr('width','91');
							$('.wide-scrollable ul li:eq('+(i-1)+')').children('img:eq('+0+')').attr('height','75');
							
							i++;
						}
						
				});
		if(!flag)
			videoObject.getItemWrap().append('<li class="noresults">No Results Found</li>');
		else if($('#main-video').length)		 
			switchVideoDetails(1);
		}//end key null
	
		videoObject.reload();		
		if(videoObject.getPageAmount() > 1) {  
			$('#video-carousel a.right').attr('class','right nextPage browse'); 
		}				
			var count = $('#video-carousel div.wide-scrollable ul li').length;
			if(count<5){ $('#video-carousel div.gallery-controls a').css('display','none'); }
			var w = 25 * Math.ceil(count/4);
			$('.gallery-controls').css({'width':w+'px'});
	
}
function switchVideoDetails(id){
	$('#tools ul li:eq(0)').children('span').attr('class','icon hidden');
	$('#tools ul li:eq(0)').children('#share-'+id).attr('class','icon');
	if($('#main-video-wrap').length)
	{	
		if(flowplayerobj != null)
			flowplayerobj.unload(); 
		$('#main-video-wrap').text(' ');
		$('#main-video-wrap').remove();
	}
	$('#main-video').append('<div id="main-video-wrap"></div>');
	var srcType = $('#videotype_'+id).text();
	var vUrl = $('#mainvideo_'+id).text();
	var vTitle = $('#fulltitle_'+id).text();
	if(srcType=='mediaserver')
		var vImg = $('#mainvideo-snapshot'+id).text();
	if(srcType=='mediaserver')
		{
			if($('#main-video-wrap').length)
			{
			 insertVideo(vUrl,vTitle,vImg);
			}
		 }
	else if(srcType=='youtube')
	{		
			$('#main-video-wrap').append('<object width="506" height="335"><param name="wmode" value="transparent"></param><param name="movie" value="'+vUrl+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+vUrl+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" width="506" height="335"></embed></object>');
			
	}
	else if(srcType=='other')
	{
	$('#main-video-wrap').append('<obect id="MediaPlayer" width="506" height="335" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject"><param name="FileName" value="'+vUrl+'"><param name="autostart" value="false"> <param name="ShowControls" value="true"><param name="ShowStatusBar" value="false"> <param name="ShowDisplay" value="false"> <embed type="application/x-mplayer2" src="'+vUrl+'" name="MediaPlayer" width="506" HEIGHT="335" ShowControls="1" ShowStatusBar="0" ShowDisplay="0" autostart="0"> </embed></object>');
	}
	
	$('#video-details div#title h3').html($('#fulltitle_'+id).text());
	$('#video-details div#tag p').html($('#tag_'+id).text()); 
	
			var url = '"http://'+ window.location.hostname +'/'+ $('#mainvideo_'+id).text()+'"';
				if($('#mainvideo_'+id).text().substr(0,7) !='http://') 
				{
						var url = '"http://'+ window.location.hostname +'/'+ $('#mainvideo_'+id).text()+'"';
				}
				else
				{
						var url ='"'+ $('#mainvideo_'+id).text()+'"';
				}
				var title = '"'+$('#fulltitle_'+id).text()+'"';
		if(!($.browser.msie && ($.browser.version == "6.0")))
			addthis.button('#share-'+id, {}, { url: url, title: title });
}

// flash : Coverflow
var flashvars = {xmlFile:"/system/xml/coverage.xml"};
//var flashvars = false;
var params = {
	wmode: "transparent"
};

function loadFlash(){
	swfobject.embedSWF("/multimedia/coverage-carousel.swf", "flash-media", "500", "275","9.0.0", "expressInstall.swf", flashvars, params);
}

function showPopup(title,path,description,currentitemindex,pdf) {
	/*if($('#media-coverage-popup').length)
	{
		$('#media-coverage-link').remove();
		$('#media-coverage-popup').remove();
	}
	$('#container').append('<button rel="#media-coverage-popup" id="media-coverage-link" type="button" class="hidden">Media Coverage Link</button><div id="media-coverage-popup" class="overlay grid_13"></div>');	
	var content = '<div id="media-coverage-details"><div class="alpha grid_3"><img src="'+imgpath+'" alt="'+title+'"/></div><div  class="grid_10 omega"><h3>'+title+'</h3><p>'+ sourcename+'</p><p>'+author+'</p><p>'+publicationdate+'</p><p>'+description+'</p></div></div>';
	$("#media-coverage-popup").html(content);
	if(pdf.length != 0)
		$('#media-coverage-details .omega').append('<span class="icon"><a href="javascript:void(0);" onclick="newWin(\''+pdf+'\'); return false;"><img alt="pdf download" src="/multimedia/high-res.png"/>Download pdf </a></span>');
	$("#media-coverage-link[rel]").overlay({expose: '#000', top : 'center'});
	$("#media-coverage-link").trigger('click');*/
	if(pdf.length != 0)
		BlankWin(pdf);
}

function insertVideo(url, title, imgSrc)	{
	flowplayerobj = $f("main-video-wrap", {src: '/multimedia/flowplayer-3.1.5.swf', wmode: 'transparent'}, {
			// change the default controlbar to tube
			plugins: {
				 controls: {
									  url: '/multimedia/flowplayer.controls-tube-3.1.5.swf',
									  borderRadius: '0px',
									  bufferGradient: 'none',
									  sliderColor: '#c9c9c9',
									  timeBgColor: '#d5d5d5',
									  volumeSliderGradient: 'none',
									  tooltipTextColor: '#000',
									  buttonOverColor: '#BA1010',
									  volumeSliderColor: '#aaaaaa',
									  progressGradient: 'medium',
									  progressColor: '#BA1010',
									  bufferColor: '#c78f8e',
									  backgroundColor: '#e1e1e1',
									  timeColor: '#000',
									  sliderGradient: 'none',
									  buttonColor: '#000',
									  durationColor: '#000',
									  tooltipColor: '#d5d5d5',
									  height: 25,
									  opacity: 1.0

								 } 
			},
			playlist: [
				{
					url: imgSrc, 
					scaling: 'fit'
				},
				{
					url: url,
					autoPlay: false
				}
			],
			canvas:
				{ 
					backgroundColor: '#ffffff' 
				}

	  });
	
   }
   	
//
function createHighlightBox(id){
//converts div with class scrollable into a highlight box
	if($('.scrollable').length)
			{
						var api=  $('#'+id).scrollable({size:1,speed:0,clickable:false,keyboard:false}).navigator({
							navi: '.controls',
							naviItem: 'a',
							api:true
						});
						var hbObj = $('#'+id+' ul li a img');
						api.onBeforeSeek(function(){		
						if(! hbObj.is(':animated'))						
							    hbObj.fadeOut(0);
							});
						api.onSeek(function(){
						if(! hbObj.is(':animated'))						
								hbObj.fadeIn(1500);
							});
						
			 }
}

function createShareThis(id){
			var iUrl  = "";                                           
				if(($('#mainimage_'+id).text()).substr(0,7) !='http://') 
					iUrl = "http://"+ window.location.hostname +'/'+$('#mainimage_'+id).text();
				else
					iUrl = $('#mainimage_'+id).text();
				var iTitle = $('#title_'+id).text().replace(/\'/g, "\\'");
				var vUrl = "http://"+ window.location.hostname +'/'+ $('#mainvideo_'+id).text();
				if($('#mainvideo_'+id).text().substr(0,7) !='http://') 
					var vUrl = "http://"+ window.location.hostname +'/'+ $('#mainvideo_'+id).text();
				else
					var vUrl = $('#mainvideo_'+id).text();
				var vTitle =$('#title_'+id).text().replace(/\'/g, "\\'");
			
			if(id==1) $('#tools ul li:eq(0)').text(' ');
			if(!($.browser.msie && ($.browser.version == "6.0")))
		    {	
				$('#tools ul li:eq(0)').attr('id','share-btns').append('<span id="share-'+id+'" class="icon hidden"><a href="javascript:void(0);"><img alt="share this" src="/multimedia/share-this.png" class="pngFix"/>Share this</a></span>');
			}
			else{

				if($('#main-image').length)
					{

						var imgUrl = "'http://www.addthis.com/bookmark.php?url="+ iUrl +"&amp;title="+ iTitle +"'" ;
						$('#tools ul li:eq(0)').attr('id','share-btns').append('<span id="share-'+id+'" class="icon hidden"><a href="http://www.addthis.com/bookmark.php?url='+ iUrl +'&amp;title='+ iTitle +'" class="addthis_button" style="text-decoration:none;" onclick="BlankWin('+imgUrl+'); return false;"><img src="/multimedia/share-this.png" class="pngFix" alt="Share" /> Share</a></span>');
					}

				else if($('#main-video').length)
					{

						var vidUrl = "'http://www.addthis.com/bookmark.php?url="+ vUrl +"&amp;title="+ vTitle +"'";
						$('#tools ul li:eq(0)').attr('id','share-btns').append('<span id="share-'+id+'" class="icon hidden"><a href="http://www.addthis.com/bookmark.php?url='+ vUrl +'&amp;title='+ vTitle +'" class="addthis_button" style="text-decoration:none;" onclick="BlankWin('+vidUrl+');return false;"><img src="/multimedia/share-this.png" class="pngFix" alt="Share" /> Share</a></span>');
					}

			
				

			}
}

function showYoutube(){
	setTimeout(function(){
		if($('#main-video-wrap embed').length)
			$('#main-video-wrap embed').css({'visibility':'visible'})
	}, 10);
}

function getUrlParameter( name ){
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results == null )
		return "";
	else
		return results[1];
}
function gotoHighlightboxSelection(href,index){
 href = href + '?selectedIndex=' + index;
 location.href = href;
}

function addThisForIE6(){
	if($.browser.msie)
	{
		if(!($.browser.version == "6.0"))
		{
			addthis.button("#share-this");
		}
		else
		{
			$('#share-this').after('<span class="icon"><a href="http://www.addthis.com/bookmark.php" class="addthis_button" onclick="BlankWin(windowUrl);return false;"> <img src="/multimedia/share-this.png"  class="pngFix" alt="Share" /> Share this</a></span>')
		}
	}
	else
		{
			addthis.button("#share-this");	
		}

}
