﻿// JScript File

var envUrl ='';
var rawXml;
var xmlPath='';

//Omniture Variables
var _ss1='Digg';
var _ss2='Google';
var _ss3='Yahoo';
var _ss4='Delicious';
var _ss5='Reddit';
var _ss6='Facebook';
var _ss7='Newsvine';
var _ss8='MyLATimes';
var _ss9='Netvibes';
var _ss10='My Yahoo';

var feedTable='';
feedTable+='/destinations/	http://feeds.latimes.com/latimes/travel/	http://xml.latimes.com/travel/rss2.0.xml\n';
feedTable+='/articles/	http://feeds.latimes.com/latimes/travel/	http://xml.latimes.com/travel/rss2.0.xml\n';


function checkUrl() {
  envUrl = '';
   if (top.location.href.indexOf('http://qa.') > -1) { envUrl = 'qa.'; }
   if (top.location.href.indexOf('http://dailybuild.') > -1) { envUrl = 'dailybuild.'; }
}

function setPath() {
	var tHref = document.location.toString();
	var tSplit = new Array();
	var sectionPath='';
	tSplit = tHref.split('/');

	if (tSplit[2]=='beta.travel.latimes.com' || tSplit[2]=='travel.latimes.com' || tSplit[2]=='qa.travel.latimes.com' || tSplit[2]=='dailybuild.travel.latimes.com') {

           if (tSplit[3] =="destinations") { sectionPath='destinations' }
           if (tSplit[3] =="articles") { sectionPath='articles' }
       
       
	var s=feedTable.indexOf(sectionPath);
     	  if (s!=-1) {
	      var v=feedTable.indexOf('\n', s+1);
	      if (v!=-1) {
	       var w=feedTable.substring(s, v);
	  	tSplit=w.split('\t');
	  	xmlPath=escape(tSplit[1]);
	  	rawXml =tSplit[2];
	      }
	     //else xmlPath='';
	  }

	}
}

function trvArticle() {
  setPath();
  checkUrl();

	var _s='&nbsp;&nbsp;&nbsp;';
	var _l=document.location.href; //+'%3Ftrack='
	var _t=document.title;
	var _y='';

	//var _digg='http://digg.com/submit?phase=2&url=' +_l+'&title='+ encodeURIComponent(_t) +'&bodytext='+ encodeURIComponent(_y); //+'&bodytext=sample abstract for story';
        var _digg='http://digg.com/submit?phase=2&url=' +_l+'&title='+ encodeURIComponent(_t) +'&bodytext='+ _y; //no need to encode bodytext';
			_digg='<a target="_new" href="'+_digg+'" onClick="setVars(_ss1)">';
			
		var _ggle='http://www.google.com/bookmarks/mark?op=add&title='+ _t+'&labels=&annotation=&bkmk=' + _l;
			_ggle='<a target="_new" href="'+_ggle+'" onClick="setVars(_ss2)">';
			
		var _yhoo='http://myweb.search.yahoo.com/myresults/bookmarklet?u='+encodeURIComponent(_l)+'&t='+escape(_t); //+'\'&popup=true';
			_yhoo='<a href="http://myweb.search.yahoo.com/" onClick="setVars(_ss3, \''+_yhoo+'\'); return false;">';
			
		var _deli='http://del.icio.us/post?v=4&noui&jump=close&url='+encodeURIComponent(_l)+'&title='+escape(_t);
			//_deli='<a href="http://del.icio.us/" onClick="void(setVars(_ss4);window.open(\''+_deli+'\', \'delicious\',\'toolbar=no,width=700,height=420\');)">';
			_deli='<a href="http://del.icio.us/" onClick="setVars(_ss4, \''+_deli+'\'); return false;" >';
			
		var _redd='http://reddit.com/submit?url='+ _l+'&title='+ _t;
			_redd='<a target="_new" href="'+_redd+'" onClick="setVars(_ss5)">';
			
		var _face2='http://www.facebook.com/sharer.php?u='+encodeURIComponent( _l)+'&t='+escape(_t);
			//_face2='<a href="http://www.facebook.com/" onClick="void(setVars(_ss6);window.open(\''+_face2+'\', \'sharer\',\'toolbar=no,width=642,height=436\');)">';
			_face2='<a href="http://www.facebook.com/" onClick="setVars(_ss6, \''+_face2+'\'); return false;" >';
			
		var _vine='http://www.newsvine.com/_wine/save?aff=latimes&h='+escape(_t)+'&e='+escape(_y)+'&u='+encodeURIComponent(_l)+'&t=';
			_vine='<a href="http://www.newsvine.com/" onClick="setVars(_ss7, \''+_vine+'\'); return false;">';


	document.write('<style type="text/css">');
	document.write('.subscribenewsheader { font: bold 12px arial, verdana, sans-serif; color: #333333; margin: 6px 0;'
	    +'border-bottom: 3px solid #6F9BB8; }');
	document.write('.subscribenewsheader a:link, .relatednewsheader a:active, .relatednewsheader a:visited,'
	    +'.relatednewsheader a:hover { color: #333; }');
	document.write('.subscribenewsheader a:link, .relatednewsheader a:active, .relatednewsheader a:visited,'
	    +'.relatednewsheader a:hover { color: #333; }');
	document.write('.articlecontent11 { font: normal 11px arial, verdana, sans-serif; color: #000; }');
	document.write('</style>');

	document.write('<div class="subscribenewsheader">SUBSCRIBE TO THIS SECTION&nbsp;'+_s
    	    //+'<a href="http://my.latimes.com/add_feed_external?link='+xmlPath+'">'
    	    //+'<a href="http://' + envUrl + 'my.latimes.com/add_feed_external?link='+xmlPath+'">'
	    +'<a href="' + rawXml + '">'
	    +'<img border=0 src="http://www.latimes.com/media/thumbnails/blurb/2007-03/22095292.gif"></a>'
	    +'</div>');

	document.write('<div id="mltpromo" class="articlecontent11" style="line-height:20px;">Click the logo below to subscribe to news from this section:<br />');
	//document.write('<a href="http://my.latimes.com/add_feed_external?link='+xmlPath
	document.write('<a href="http://'+ envUrl +'my.latimes.com/add_feed_external?link='+xmlPath
	    +'" onClick="setVars(_ss8)"><img border=0 src="http://www.latimes.com/images/mylatimes/mlt.gif" title="Add to MyLATimes"></a><br /><br />');
	document.write('Or add this feed to your favorite RSS reader:<br />');
	document.write('<a href="http://www.netvibes.com/subscribe.php?url='+xmlPath+'" onClick="setVars(_ss9)"><img border=0 title="Add to Netvibes" alt="Add to Netvibes"'+' src="http://www.latimes.com/images/mylatimes/netvibes.jpg" align="absmiddle"/></a>'+_s+_s+_s);
	document.write('<a href="http://add.my.yahoo.com/rss?url='+xmlPath+'" onClick="setVars(_ss10)"><img title="Add to My Yahoo!" alt="Add to My Yahoo!" align="absmiddle"'+' src="http://www.latimes.com/images/mylatimes/myyahoo.jpg" border="0"></a>'+_s+_s+_s);
	document.write('<a href="http://feeds.latimes.com/latimes/travel">more</a><br /><br />');
	document.write('SAVE AND SHARE<br />');
	document.write(_ggle+'<img border=0 src="http://www.latimes.com/images/mylatimes/google.gif" title="Google">'+'</a>'+_s+_s);
	document.write(_digg+'<img border=0 src="http://www.latimes.com/images/mylatimes/digg.gif" title="Digg">'+'</a>'+_s+_s);
	document.write(_deli+'<img border=0 src="http://www.latimes.com/images/mylatimes/delicious.gif" title="Del.icio.us">'+'</a>'+_s+_s);
	document.write(_face2+'<img border=0 src="http://www.latimes.com/images/mylatimes/facebook.gif" title="Facebook">'+'</a>'+_s+_s);
	document.write(_redd+'<img border=0 src="http://www.latimes.com/images/mylatimes/reddit.gif" title="Reddit">'+'</a>'+_s+_s);
	document.write(_yhoo+'<img border=0 src="http://www.latimes.com/images/mylatimes/yahoo.gif" title="Yahoo">'+'</a>'+_s+_s);
	document.write(_vine+'<img border=0 src="http://www.latimes.com/images/mylatimes/newsvine.gif" title="Newsvine">'+'</a>'+_s+_s);
	document.write('</div>');
	document.write('<br clear="all" />');
}

function trvSection() {
  setPath();
  checkUrl();

	document.write('<div id="syndicate"><p class="header-sect"><span class="rssimg">'
	  +' <a href="http://feeds.latimes.com/latimes/travel">'
	  +' <img src="http://www.latimes.com/images/mylatimes/rss_icon2.jpg" width="28" height="14" border="0" /></a></span>'
	  +' <span class="blog-title">Subscribe to This Section</span></p>');

	//document.write('<div><a href="http://my.latimes.com/add_feed_external?link='+xmlPath+'">'
	document.write('<div><a href="http://'+ envUrl + 'my.latimes.com/add_feed_external?link='+xmlPath+'">'
	
	  +'<img src="http://www.latimes.com/images/mylatimes/mlt.gif" border="0" /></a>'
	  +'<p>or add to your preferred website</p>');

	document.write('<form name="rssform">');
	document.write('<select name="dest" onchange="window.location.href=this[selectedIndex].value;">'
	  +'<option value="">Select a Site</option>'
	  +'<option value="http://add.my.yahoo.com/rss?url='+xmlPath+'">MY YAHOO</option>'
	  +'<option value="http://www.newsgator.com/ngs/subscriber/subext.aspx?url='+xmlPath+'">NEWSGATOR</option>'
	  +'<option value="http://feeds.my.aol.com/add.jsp?url='+xmlPath+'">MY AOL</option>'
	  +'<option value="http://www.rojo.com/add-subscription?resource='+xmlPath+'">ROJO</option>'
	  +'<option value="http://www.bloglines.com/sub/'+xmlPath+'">BLOGLINES</option>'
	  +'<option value="http://www.netvibes.com/subscribe.php?url='+xmlPath+'">NETVIBES</option>'
	  +'<option value="http://fusion.google.com/add?feedurl='+xmlPath+'">GOOGLE</option>'
	  +'<option value="http://www.pageflakes.com/subscribe.aspx?url='+xmlPath+'">PAGEFLAKES</option>'
	  +'</select></form>'
	  +'</div></div>');
}


function trvBlog() {
  checkUrl();
  xmlPath="http://feeds.latimes.com/DailyDealsLosAngelesTimesTravel"; 

	document.write('<div id="syndicate"><p class="header-sect"><span class="rssimg">'
	  +' <a href="http://feeds.latimes.com/DailyDealsLosAngelesTimesTravel">'
	  +' <img src="http://www.latimes.com/images/mylatimes/rss_icon2.jpg" width="28" height="14" border="0" /></a></span>'
	  +' <span class="blog-title">Subscribe to this blog</span></p>');

	//document.write('<div><a href="http://my.latimes.com/user_feed?link='+xmlPath+'">'
	document.write('<div><a href="http://' + envUrl + 'my.latimes.com/add_feed_external?link='+xmlPath+'">'
	  +'<img src="http://www.latimes.com/images/mylatimes/mlt.gif" border="0" /></a>'
	  +'<p>or add to your preferred website</p>');

	document.write('<form name="rssform">');
	document.write('<select name="dest" onchange="window.location.href=this[selectedIndex].value;">'
	  +'<option value="">Select a Site</option>'
	  +'<option value="http://add.my.yahoo.com/rss?url='+xmlPath+'">MY YAHOO</option>'
	  +'<option value="http://www.newsgator.com/ngs/subscriber/subext.aspx?url='+xmlPath+'">NEWSGATOR</option>'
	  +'<option value="http://feeds.my.aol.com/add.jsp?url='+xmlPath+'">MY AOL</option>'
	  +'<option value="http://www.rojo.com/add-subscription?resource='+xmlPath+'">ROJO</option>'
	  +'<option value="http://www.bloglines.com/sub/'+xmlPath+'">BLOGLINES</option>'
	  +'<option value="http://www.netvibes.com/subscribe.php?url='+xmlPath+'">NETVIBES</option>'
	  +'<option value="http://fusion.google.com/add?feedurl='+xmlPath+'">GOOGLE</option>'
	  +'<option value="http://www.pageflakes.com/subscribe.aspx?url='+xmlPath+'">PAGEFLAKES</option>'
	  +'</select></form>'
	  +'</div></div>');
}

function setVars(oVar, oData){
	if (oVar=='Yahoo') void(window.open(oData, 'MyWeb', 'toolbar=no,width=700,height=400'));
	else if (oVar=='Delicious') void(window.open(oData, 'delicious', 'toolbar=no,width=700,height=420'));
	else if (oVar=='Facebook') void(window.open(oData, 'sharer', 'toolbar=no,width=642,height=436'));
	else if (oVar=='Newsvine') void(window.open(oData, 'newsvine', 'width=650,height=445,resizable=no,scrollbars=no'));
	
   omnVar = oVar;
   //alert(omnVar);
   var s=s_gi(s_account);
     s.linkTrackVars='events,eVar27';
     s.linkTrackEvents='event11';
     s.events='event11';
     s.eVar27= omnVar;
     void(s.tl(this,'o','Social Bookmark Click')); 
     s.events = '';
     s.eVar27 = '';
     s.linkTrackVars = 'None';
     s.linkTrackEvents = 'None'; 
}