// ------------------------ 10util.js starts here -----------------------------
/*              Utility functions                    */

function addEvent(obj, eventType, fn){
  /* adds an eventListener for browsers which support it
     Written by Scott Andrew: nice one, Scott */
     
  if( eventType === "load" ) {
  	//hack me
  	loadEventList.addLoadEvent(fn);
  	return true;
  }     
     
  if (obj.addEventListener){
    obj.addEventListener(eventType, fn, false);
    return true;
  } else if (obj.attachEvent){
	var r = obj.attachEvent("on"+eventType, fn);
    return r;
  } else {
	return false;
  }
}

var loadEventList = [];
loadEventList.addLoadEvent = function( fn ) {
	loadEventList[ loadEventList.length ] = fn;
}

loadEventList.fireLoadEvents = function() {
	for(var i=0; i<loadEventList.length; i++) {
		loadEventList[i]();
	}
}

/* the following is a hack to replicate DOMContentLoaded in browsers
   other than Firefox.  It is basically copied from
   http://dean.edwards.name/weblog/2006/06/again/
*/
if(/WebKit/i.test(navigator.userAgent)) { // Safari
	var _timer = setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
			clearInterval(_timer);
			loadEventList.fireLoadEvents(); // call the onload handler
		}
	}, 100);
} else if (document.addEventListener) {
	document.addEventListener("DOMContentLoaded", loadEventList.fireLoadEvents, false);
} else {
  // IE HACK
/*@cc_on @*/
/*@if (@_win32)
document.write("<script id='__ie_onload' defer='defer' src='//:'><\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
	if (this.readyState == "complete") {
		loadEventList.fireLoadEvents(); // call the onload handler
	}
};
/*@end @*/
}



function openGalleryPopup(url) {
	var maxAvaliableHeight = screen.availHeight;

	maxAvaliableHeight = maxAvaliableHeight - 86; 
	openGalleryPopup(url,maxAvaliableHeight);
}

function openGalleryPopup(url,height) {
	var galleryWidth=830;
	
	var leftPos = 0;
	if(screen.availWidth > galleryWidth) {
		leftPos = Math.round((screen.availWidth - galleryWidth) / 2)
	}
	
	var newWindow = window.open(url, 'GUGalleryPopup', 'resizable=yes,scrollbars=yes,location=yes,toolbar=yes,status=no,top=0,left=' + leftPos + ',height=' + height + ',width=' + galleryWidth);
	newWindow.screenX = leftPos;
	newWindow.screenY = 0;
	
	return false;
	
}
// ------------------------- 10util.js ends here ------------------------------
// ---------------------- ad_support.js starts here ---------------------------
// Time out is in minutes
var hoursToCount = 0; // Set this to make the cookie _not_ be session based (that is, an expire field is set)
var timeOut = 720;
var maxAdCount = 100;
var showAdsOnNthVideo = 2;

function buildIntrusiveAd(adHost, geoCountry, geoRegion, geoCity, geoBandwidth, randString, commercialFolder, keywords, pageUrl, site, system) {
	var theseCookies = document.cookie;
	var pos = theseCookies.indexOf('GUDHTMLAds=');
	if 	(pos == -1) {
		var seconds = 180;
		var expireTime = new Date();
		var currenttimeinmills = expireTime.getTime();
		expireTime.setTime(currenttimeinmills + seconds * 1000 );
		document.cookie = 'GUDHTMLAds=Dummy; expires=' + expireTime.toGMTString() + ' ; path=/ ; domain=guardian.co.uk';
		
        var	intrusad = 
            '<' + 'script type="text/javascript" src="' + adHost + 
            '/js.ng/spacedesc=01&amp;comfolder=' + commercialFolder + 
            '&amp;keywords=' + keywords + 
            '&amp;country=' + geoCountry + 
            '&amp;region=' + geoRegion + 
            '&amp;city=' + geoCity + 
            '&amp;bandwidth=' + geoBandwidth + 
            '&amp;rand=' + randString + 
			'&amp;site=' + site +
            '&amp;url=' + pageUrl +  
			'&amp;system=' + system + '"></' + 'script>';
            
		document.write(intrusad);
		document.close();
	}
}

function AdCookieValue() {
	this.date = new Date();
	this.date.setTime(0);
	this.adsPlayed = 0;
	this.videosPlayed = 0;
	
	if (hoursToCount != 0) {
		var t = new Date().getTime();
		t += hoursToCount * 1000 * 60 * 60;
		this.expiryDate = new Date();
		this.expiryDate.setTime(t);
	}
}

AdCookieValue.prototype.adDisplayed = function() {
	this.adsPlayed++;
	this.date = new Date();
}

AdCookieValue.prototype.videoDisplayed = function() {
	this.videosPlayed++;
}

AdCookieValue.prototype.shouldDisplayAdvert = function() {
	return this.videosPlayed % showAdsOnNthVideo == 0;  
}

AdCookieValue.parseText = function(text) {
	var bits = text.split("|");
	var cookieValue = new AdCookieValue();
	cookieValue.adsPlayed = bits[0] - 0;
	cookieValue.videosPlayed = bits[1] - 0;
	cookieValue.date.setTime(Date.parse(bits[2]));
	if (hoursToCount != 0 && bits[3]) {
		cookieValue.expiryDate.setTime(Date.parse(bits[3]));
	}
	return cookieValue;
}

AdCookieValue.prototype.toString = function() {
	if (hoursToCount != 0) {
		return this.adsPlayed + "|" + this.videosPlayed + "|" + this.date + "|" + this.expiryDate;
	} 
	return this.adsPlayed + "|" + this.videosPlayed + "|" + this.date;
}

AdCookieValue.loadFromCookie = function() {
	var cookies = document.cookie.split(';');
	
	for (var i = 0; i < cookies.length; i++) {
		var nameValuePair = cookies[i].split('=');
		if (nameValuePair[0].charAt(0) == ' ') {
			nameValuePair[0] = nameValuePair[0].substring(1, nameValuePair[0].length);
		}
		
		if (nameValuePair[0] == "GUVidAd") {
			return AdCookieValue.parseText(nameValuePair[1]);
		}
	}
	
	return new AdCookieValue();
}

function isVideoAdDisplayed() {
	return AdCookieValue.loadFromCookie().shouldDisplayAdvert();
}

function videoAdPlayed(domain) {
	var cookieValue = AdCookieValue.loadFromCookie();
	cookieValue.adDisplayed();
	writeCookie(domain, cookieValue);
}

function videoPlayed(domain) {
	var cookieValue = AdCookieValue.loadFromCookie();
	cookieValue.videoDisplayed();
	writeCookie(domain, cookieValue);
}

function writeCookie(domain, cookieValue) {
	var cookieString;
	if (hoursToCount != 0) {
		cookieString = "GUVidAd=" + cookieValue.toString() + "; expires=" + cookieValue.expiryDate.toGMTString() + " ; path=/ ; domain=" + domain;
	} else {
		cookieString = "GUVidAd=" + cookieValue.toString() + "; path=/ ; domain=" + domain;
	}
	document.cookie = cookieString;
}

// ----------------------- ad_support.js ends here ----------------------------
// ------------------------ caption.js starts here ----------------------------
addEvent(window, "load", caption); 

function caption ()  {
	var imageList=document.getElementsByTagName('li');
	
	
	for(var i=0; i<imageList.length; i++){
	
		if(imageList[i].className.match(/\bpixie\b/))  {
			imageList[i].onmouseover= function () { changeState(this, 'over') };
			imageList[i].onmouseout=  function () { changeState(this,'off') };
			imageList[i].onfocus= function () { changeState(this, 'over') };
			imageList[i].onblur=  function () { changeState(this, 'off') };
			}
		}
}		
		
function changeState(element,state)  {
	var existingClassName=oldClassName(element,'static-state');
	
	if (element.className.match(/c-[0-9]+-c/)) {
		var timeOutHide=element.className.match(/[0-9]+/);
		timeOutHide=parseInt(timeOutHide);
		clearInterval(timeOutHide);
	}
	if(element.getElementsByTagName('div')[1].className.match('trail-text')) {
		var elementRef=element.getElementsByTagName('div')[1];
		var timeOutRef=setInterval(function (){ show(elementRef, state) }, 10);
		element.className=existingClassName+"c-"+timeOutRef+"-c";
	}
}

function show(element, state)  {

	var startPosition=-4;
	var endPosition=1.4;
	var rate=1;
	
	var captionPosition=parseInt(element.style.marginTop);
	if(isNaN(captionPosition)) {
		captionPosition=startPosition;
		
	}else if(state=='over'){	
		captionPosition=captionPosition+rate;
	}else{
		captionPosition=captionPosition-rate;
	}
	
	if (captionPosition<=endPosition && state=='over' || captionPosition>=startPosition && state=='off') {
		element.style.marginTop=captionPosition+'em';
	}else{
		var timeOut=element.parentNode.className.match(/[0-9]+/);
		var existingClassName=oldClassName(element.parentNode,'static-state');
		element.parentNode.className=existingClassName+"static-state";
		timeOut=parseInt(timeOut);		
		if(!isNaN(timeOut)) clearInterval(timeOut);
	}
}

/*
	for later use?
*/
function oldClassName (element, modificationClass)  {
	var oldClass='';
	
	if (element.className) {
		oldClass=element.className;
	}else{
		return oldClass;
	}
	if (oldClass.match(/(\bmodificationClass\b)|(c-[0-9]+-c)/))  {
		var newClass=oldClass.replace(/(\bmodificationClass\b)|(c-[0-9]+-c)/, "")
		 newClass=newClass.replace(modificationClass, "")
	} else {
		var newClass=oldClass+" ";
	}
	
	return newClass;
}
// ------------------------- caption.js ends here -----------------------------
// ------------------------ clear.js starts here ------------------------------
addEvent(window, "load", handleText); 
function handleText ()  {
	if (!document.getElementsByTagName) return;
	var inputFields=document.getElementsByTagName('input');
	for (var i=0; i<inputFields.length; i++)  {
		if (inputFields[i].className.match(/\bsearch-field\b/))  {
			inputFields[i].onfocus= function () {
		
				clearText(this);
			}
			
			inputFields[i].onblur= function () {
			
				setText(this);
			}
			
		}
	}
	
}


function clearText (e)  {
	var curentText=e.value;
	var defaultText=e.getAttribute('title');
	if (curentText==defaultText) e.value ='';
	
}

function setText (e)  {
	var curentText=e.value;
	var defaultText=e.getAttribute('title');	
	if (curentText=='') e.value =defaultText;
}
// ------------------------- clear.js ends here -------------------------------
// --------------------- convert-png.js starts here ---------------------------
/*@cc_on @*/
/*@if (@_jscript_version <= 5.6)
// The above conditional compilation for IE is equivalent to
// a conditional comment in HTML of 'if lte IE 6'

addEvent(window, "load", doPng); 

function doPng()  {

	var pngs=document.getElementsByTagName('img');
	

	if(pngs.length==0) return;
	for(var i=0; i<pngs.length; i++){
		if(pngs[i].src.match(/\.png$/) && !pngs[i].src.match("/reuters/")){
			var newImage=document.createElement("div");
			newImage.style.width=pngs[i].width+'px';
			newImage.style.height=pngs[i].height+'px';
			newImage.id=pngs[i].id;
			newImage.className=pngs[i].className;
			var mask=pngs[i].src;
			newImage.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+mask+"',sizingMethod='scale')";
			
			var parent=pngs[i].parentNode;
			parent.replaceChild(newImage, pngs[i]);
		}
	}
	
}
/*@end @*/
// ---------------------- convert-png.js ends here ----------------------------
// ---------------------- drop-cap.js starts here -----------------------------
function dropCaps()  {

	var timeout=setInterval(pollContent, 100);

function pollContent()  {
	try {
		doDropCap();
		clearInterval (timeout);
		
	}
	catch (e)  {
	
	}
	}
	function doDropCap ()  {

		if (!document.getElementById) return;
		if(!document.getElementsByTagName('body')[0].className.match('article')) return;
		var content=document.getElementById('content');

		var oldClassName, previousTag;
		var subEditor=content.getElementsByTagName('strong');

		for(var j=0; j<subEditor.length; j++)  {
			if (subEditor[j].className.match("drop")) return;	
		
		}
		var article=content.getElementsByTagName('p');
		var classNameValue='drop';
		for (var i=0; i<article.length; i++)  {
				
			if (article[i].parentNode.id.match('content'))
				{
				previousTag=article[i].previousSibling.tagName;
					
					if(article[i].textContent) 	{
						var paraText=article[i].textContent;
						}else{
						var paraText=article[i].innerText;
						}

					if (paraText.length>400)  {
					
						
					
						if( paraText.match(/^Q/))  {
							classNameValue+=' q';
							} else {
								classNameValue='drop'
							
							}
							if(i<2 && !article[i].className.match('caption'))  {
						if (article[i].className) ClassNameValue+=' '+article[i].className.value;
						article[i].className=classNameValue;
						break;
						}
					}
				}
		}
		
	}
}
dropCaps();
// ----------------------- drop-cap.js ends here ------------------------------
// --------------------- font-sizer.js starts here ----------------------------
/*
	this script adjusts the font-size of the document in 10% increments.
	it checks for the sizing-widget id and then attaches click events 
	it also sets a cookie to rember the font size for 1 year form the last visit

*/

/*
	if javascript is turned off the links goto larger.html and smaller.html
	these pages should explain about what the widget is for and how to adjust 
	the font-size in the browser...
*/

addEvent(window, "load", fontSizer);
addEvent(window, "load", setFontSize);


function fontSizer()
{
	if (!document.getElementById) return false;
	
	
	
	if(document.getElementById('larger') && document.getElementById('smaller'))  {
		var increase=document.getElementById('larger');
		var decrease=document.getElementById('smaller');
		
		increase.style.display="inline";
		decrease.style.display="inline";
		
		var myDate= new Date();
		expires=myDate.getFullYear()+1
		myDate.setFullYear(expires);
		expires='; expires='+myDate.toGMTString();
		
		increase.onclick= function() {
			//get the calculated font-size
			if (document.getElementsByTagName('body')[0].style.fontSize)  {
				var currentSize=document.getElementsByTagName('body')[0].style.fontSize;
				
				currentSize=currentSize.match(/([0-9]+)/);
				currentSize=(Number(currentSize[0])+10)+'%';

			}else{//no calculated font size so we are just starting
				var currentSize='110%';
			}
			
			document.getElementsByTagName('body')[0].style.fontSize=currentSize;
			document.cookie="fontSize="+currentSize+expires;
			return false;
		}
		
		decrease.onclick= function() {
			//get the calculated font-size
			if (document.getElementsByTagName('body')[0].style.fontSize)  {
				var currentSize=document.getElementsByTagName('body')[0].style.fontSize;
				currentSize=currentSize.match(/([0-9]+)/);
				currentSize=(Number(currentSize[0])-10);
				if (currentSize<60) currentSize=60;
				currentSize=currentSize+'%';
			}else{//no calculated font size so we are just starting
				var currentSize='90%';
			}
			document.getElementsByTagName('body')[0].style.fontSize=currentSize;
			document.cookie="fontSize="+currentSize+expires;
			return false;
			

		}
		
	
	}
}

/*
	Get the cookie and set the adjusted font-size
*/

function setFontSize ()  {
	var cookies=document.cookie;
	var cookieList=cookies.split(';');
	var fontSize='';

	for ( var i=0; i<cookieList.length; i++)  {
		if (cookieList[i].match('fontSize')) fontSize=cookieList[i];
	}
		if (fontSize)  {	
			fontSize=fontSize.match((/([0-9]+\%)/))[0];
			document.getElementsByTagName('body')[0].style.fontSize=fontSize;
		}
		
}
// ---------------------- font-sizer.js ends here -----------------------------
// -----------------------formChecker.js starts here ------------------------------

function formChecker(elem, limit) {
var warning = document.getElementById('warning');
var charsLeft = limit-elem.value.length;
	warning.innerHTML=charsLeft + ' characters left';
	warning.className = "";
	if(elem.value.length>limit) {
	elem.value=elem.value.substring(0,limit);
	warning.innerHTML = "Max 250 characters";
	warning.className = "warning";
	elem.scrollTop = elem.scrollHeight - elem.clientHeight;
	}
}

addEvent(window, "load", menu); 

//new function to encapsulate all the others and prevent global leakage

function menu(){


show();
galleryIntro();


function galleryIntro()  {

	if(!document.getElementById || !document.getElementById("shower")) return;
	var target, idValue;
	idValue = document.getElementById("shower");
	target=idValue.href.match(/#.*/);

	target=target.toString(); //to turn into a string
	target=target.replace('#',''); //strips out the hash 
	var more=document.getElementById(target); //to keep this local 
	
	var rightPosition = calculateRightPosition();
		//var leftPosition = calculateLeftPosition();
//	more.style.right = rightPosition + "px";
	//why set the top here?
	//more.style.top = "10px";
	more.style.display = "block";
	more.style.right = rightPosition + "px";
    
	
	if(document.getElementById("portrait-caption")){
	var width = calculateWidth ();
	var caption = document.getElementById("portrait-caption");
	//caption.style.right = rightPosition + "px";
	
	}
}


function show() {
	if(!document.getElementById || !document.getElementById("overlay-wrapper")) return;
	var overlay = document.getElementById("overlay-wrapper");
	var controller = document.getElementById("shower");

	var width=calculateWidth();
	
	overlay.style.width=width + 'px';
	if(overlay.filters) {
	    overlay.style.zoom='1';
	}
	controller.onclick = function () {
	
			try {
				clearInterval (abinterval);
			}
			catch(e){}
		timeout();
		flag= flag==false ? true : false;
		
		var state = overlay.className;
		
		if(state.match("gallery-on")){
			state = state.replace("gallery-on","gallery-off");
			//overlay.style.width='0.25em';
		}else{
		
			state = state.replace("gallery-off","gallery-on");
			//overlay.style.width=width + 'px';	
		}
		overlay.className = state;
		return false;
	}
}


function calculateRightPosition ()  {
	var mainPicture = document.getElementById('main-picture');
	var width = mainPicture.width;



	if (width<500)  {

		var rightPosition = 630 - width + 10;
		
	}
	else  {
		var rightPosition = 10; //positions block
	}
	return rightPosition;
}



function calculateWidth ()  {

	var mainPicture = document.getElementById('main-picture');
	var width = mainPicture.width;
	if(width<500)  {
			var freespace=250;
	}
	else {
		var freespace=300;
	}

	return freespace;

}

var fader = 90; 
var abinterval;
var flag=false;
function fadeout() {
	var overlay = document.getElementById("overlay");
	if(overlay.filters) {
	
	overlay.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=" + fader + ")";
	//seem to need this here to make opacity work don't know why...
    overlay.style.zoom='1';
	fader = fader -5;
	}else
	{
		overlay.style.opacity = fader/100;
		fader = fader -5;
	}
	if (fader < 0.00) {
		clearInterval (abinterval);
		overlay.style.opacity = -2.000;
	}
}


function fadein() {
	var overlay = document.getElementById("overlay");
	
	if(overlay.filters) {
		overlay.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=" + fader + ")";
		fader = fader +5;
	}else{
	
	overlay.style.opacity = fader/100;
	fader = fader + 5;
	
}
if (fader > 90) clearInterval (abinterval);
}

function timeout() {
	if(flag==false) {
				abinterval = setInterval (fadeout, 100);
	}
	
	


	if(flag==true) {
		abinterval = setInterval (fadein, 100);
	}
}


}

/*
Pull down navigation handler

*/
addEvent(window, "load", GUgetUrl);

function GUgetUrl()  {
	if (!document.getElementById('go-to')) return;
	
	var myUrl=document.getElementById('go-to');
	for(var i=0; i<myUrl.length;i++)  {

		myUrl.onchange=function ()  {
						
			window.top.location=this.value;
		}
	}
	
	

}
// ------------------------ more.js starts here -------------------------------
addEvent(window, "load", more); 

function more()  {
	if(!document.getElementById) return;
	var target, idValue;
	var n=0;
	var more= new Array();
	
	var showers=document.getElementsByTagName('a');
	for (var i=0;i<showers.length; i++)  {

		target=showers[i].href;
		if(target.match(/#.*/))  {
		
			if(showers[i].className.match('shower'))  {
				
				
				showers[i].onclick=function (e, n)  {
					target=this.href;
					idValue=target.match(/#.*/);
					idValue=idValue.toString();
					idValue=idValue.replace('#','');
					more=document.getElementById(idValue);
					if (!this.className.match('open'))  {
						if(this.className)
							{
								var oldClassName=this.className;
								this.className=this.className+' open';
							}else{
								this.className="open"
							}
						more.style.display='block';
						if (!e) var e = window.event;
						if (e.clientY>120)
							{
									window.scrollBy(0,100);
							}
					}else{
						var oldClassName=this.className
						oldClassName=oldClassName.replace(/ ?open/,'');
						this.className=oldClassName;
						
						more.style.display='none';
						//this.className="closed";
					}
	
					return false;
				}
			}
		}
	}	
}

//event.clientY ie
// ------------------------- more.js ends here --------------------------------


// ------------------------ openCurrent.js starts here -------------------------------


function openCurrent()  {
	if(!document.getElementById) return;
	
	var current=document.getElementById('current');
	var par = current;
	while (par) {
		par = par.parentNode;
		if (par.id == "book-index" ) {
			var currentArrow = current.parentNode.parentNode.parentNode.firstChild.nextSibling.firstChild.nextSibling;
			var currentList = current.parentNode.parentNode.id;
			currentArrow.className+=' open';
			var lists=document.getElementsByTagName('ul');
			for ( var i = 0; i<lists.length; i++ ) {
				if ( lists[i].id.match(/drop*/) && lists[i].id !== currentList) {
					lists[i].style.display='none';
				}	
			}
			break;
		}
	}
}

// ------------------------- openCurrent.js ends here --------------------------------
// ---------------------- search-bg.js starts here ----------------------------
addEvent(window, "load", guWebSearch); 

function guWebSearch() {

    if(!document.getElementById('search-web') || !document.getElementById('web-search-field')) return;
    var radioButton=document.getElementById('search-web');
    var searchField = document.getElementById('web-search-field');
    
    document.getElementById('search-web').onclick = function () { doSearchBg(this); }
    
    document.getElementById('search-guardian').onclick =  function () { doSearchBg(this); }
    
    if(document.getElementById('search-section')) {
        document.getElementById('search-section').onclick =  function () { doSearchBg(this); }
    }
    
    
    function doSearchBg(elementRef) {
    
       if (elementRef.id!="search-web") {
      
            searchField.className = searchField.className.replace(/\bweb-search\b/, '');
       }else if(!searchField.className.match(/\bweb-search\b/)) {
            searchField.className = searchField.className + ' web-search';
       }
    }   
    
}
// ----------------------- search-bg.js ends here -----------------------------
// ----------------------- search.js starts here ------------------------------
function SearchForm(browseHost, yahooBackgroundImage) {
	var that = this;
	
	this.browseHost = browseHost;
	this.yahooBackgroundImage = yahooBackgroundImage; 

	var searchForm = document.getElementById("search");
	if(searchForm) {
	addEvent(searchForm, 'submit', checkSubmit);
	}
	
	function changeSearchBackground(t) {
		document.getElementById("web-search-field").style.backgroundImage = t;
	}
	
	function checkSubmit(e) {
		var textField = document.getElementById('web-search-field');
	
		var form = document.getElementById('search');
		
		if (document.getElementById("search-web").checked) {
			_hbLink ('{header}{search-yahoo}','{header}');
			textField.name = 'p';
			form.action = 'http://uk.search.yahoo.com/search';
		} else if (document.getElementById("search-section") && document.getElementById("search-section").checked) {
			_hbLink ('{header}{search-section}','{header}');
			textField.name = 'search';
			form.action = that.browseHost + '/search/' + document.getElementById("search-section").value;
		} else {
			_hbLink ('{header}{search-gu}','{header}');
			textField.name = 'search';
			form.action =  that.browseHost +  '/search';
		}
				
		return true;
	}
	
}
// ------------------------- search.js ends here ------------------------------
// ------------------------ sendtoafriend.js starts here -------------------------------

addEvent(window, "load", sendtoafriend); 

function sendtoafriend() {

if ( (!document.getElementById("send-share") ) || (!document.getElementById("send-email") ) ) return;
var shares=document.getElementsByTagName('a');
	for (var i=0;i<shares.length; i++)  {
	var shareclass=shares[i].className;
		if(shareclass.match('sendthis'))  {
			shares[i].onclick=function (e)  {
			if (this.id=="sharelink") {
				var clicked = document.getElementById('send-share');
				if (clicked.style.display == "block") {
					clicked.style.display = "none";
				}
				else {
					clicked.style.display = "block";
					document.getElementById("send-email").style.display = "none";
					if (!e) var e = window.event;
						if (e.clientY>500)
							{
									window.scrollBy(0,200);
							}
				}
				
			}
			
			else if (this.id=="sendlink") {
				var clicked = document.getElementById('send-email');
				if (clicked.style.display == "block") {
					clicked.style.display = "none";
				}
				else {
					clicked.style.display = "block";
					document.getElementById("send-share").style.display = "none";
					if (!e) var e = window.event;
						if (e.clientY>500)
							{
									window.scrollBy(0,200);
							}
				}
				
			}
			
			else {
				document.getElementById("send-share").style.display = "none";
				document.getElementById("send-email").style.display = "none";
			}
		return false;
		}
	}
}
}

// ------------------------ sendtoafriend.js ends here -------------------------------
// ---------------------- signedin.js starts here -----------------------------


function UrlStack(cookieDomain) {
	this.cookieDomain = cookieDomain;
}

UrlStack.prototype.getCookieForUrlStack = function (name) {
	if (!document.cookie) {
		return '';
	}
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else
		begin += 2;

	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
	end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}

UrlStack.prototype.setCookieForUrlStack = function (name, value) {
  var curCookie = name + "=" + escape(value) +
      "; domain="+this.cookieDomain+"; path=/"
  document.cookie = curCookie;
}

UrlStack.prototype.pushUrlOntoStack = function(url) {
	var cookie = this.getCookieForUrlStack('GU_ST');
	var stack = cookie ? cookie.split('|') : new Array();

	if(stack.length == 0 || (stack.length > 0 && stack[stack.length-1] != url)) {
		stack[stack.length] = url;
		this.setCookieForUrlStack('GU_ST',stack.join('|'));
	}
	return true;
}
UrlStack.prototype.URLStack_pop = function() {
	var cookie = '|' + this.getCookieForUrlStack('GU_ST');
	var x = cookie.lastIndexOf('|');
	var url = cookie.substring(x + 1);
	this.setCookieForUrlStack('GU_ST',cookie.substring(0, x));
	return url;
}

UrlStack.prototype.clearUrlStack = function() {
	if (this.getCookieForUrlStack('GU_ST') != '') {
		this.setCookieForUrlStack('GU_ST','');
	}
}

function signIn() {
	urlStack.pushUrlOntoStack(document.location);
	window.location="/Users/signin/0,,-1,00.html";
	return false;
}

function register() {
	urlStack.pushUrlOntoStack(document.location);
	window.location="/Users/register/1,,-1,00.html";
	return false;
}

function signOut() {
    urlStack.pushUrlOntoStack(document.location);
    window.location = "/Users/signout/tr/1,,,00.html";
    return false;
}

// ----------------------- signedin.js ends here ------------------------------
// ----------------- textresizedetector.js starts here ------------------------
/** 
 *  @fileoverview TextResizeDetector
 * 
 *  Detects changes to font sizes when user changes browser settings
 *  <br>Fires a custom event with the following data:<br><br>
 * 	iBase  : base font size  	
 *	iDelta : difference in pixels from previous setting<br>
 *  	iSize  : size in pixel of text<br>
 *  
 *  * @author Lawrence Carvalho carvalho@uk.yahoo-inc.com
 * @version 1.0
 */

/**
 * @constructor
 */
TextResizeDetector = function() { 
    var el  = null;
	var iIntervalDelay  = 200;
	var iInterval = null;
	var iCurrSize = -1;
	var iBase = -1;
 	var aListeners = [];
 	var createControlElement = function() {
	 	el = document.createElement('span');
		el.id='textResizeControl';
		el.innerHTML='&nbsp;';
		el.style.position="absolute";
		el.style.left="-9999px";
		var elC = document.getElementById(TextResizeDetector.TARGET_ELEMENT_ID);
		// insert before firstChild
		if (elC)
			elC.insertBefore(el,elC.firstChild);
		iBase = iCurrSize = TextResizeDetector.getSize();
 	};

 	function _stopDetector() {
		window.clearInterval(iInterval);
		iInterval=null;
	};
	function _startDetector() {
		if (!iInterval) {
			iInterval = window.setInterval('TextResizeDetector.detect()',iIntervalDelay);
		}
	};
 	
 	 function _detect() {
 		var iNewSize = TextResizeDetector.getSize();
		
 		if(iNewSize!== iCurrSize) {
			for (var 	i=0;i <aListeners.length;i++) {
				aListnr = aListeners[i];
				var oArgs = {  iBase: iBase,iDelta:((iCurrSize!=-1) ? iNewSize - iCurrSize + 'px' : "0px"),iSize:iCurrSize = iNewSize};
				if (!aListnr.obj) {
					aListnr.fn('textSizeChanged',[oArgs]);
				}
				else  {
					aListnr.fn.apply(aListnr.obj,['textSizeChanged',[oArgs]]);
				}
			}

 		}
 		return iCurrSize;
 	};
	var onAvailable = function() {
		
		if (!TextResizeDetector.onAvailableCount_i ) {
			TextResizeDetector.onAvailableCount_i =0;
		}

		if (document.getElementById(TextResizeDetector.TARGET_ELEMENT_ID)) {
			TextResizeDetector.init();
			if (TextResizeDetector.USER_INIT_FUNC){
				TextResizeDetector.USER_INIT_FUNC();
			}
			TextResizeDetector.onAvailableCount_i = null;
		}
		else {
			if (TextResizeDetector.onAvailableCount_i<600) {
	  	 	    TextResizeDetector.onAvailableCount_i++;
				setTimeout(onAvailable,200)
			}
		}
	};
	setTimeout(onAvailable,500);

 	return {
		 	/*
		 	 * Initializes the detector
		 	 * 
		 	 * @param {String} sId The id of the element in which to create the control element
		 	 */
		 	init: function() {
		 		
		 		createControlElement();		
				_startDetector();
 			},
			/**
			 * Adds listeners to the ontextsizechange event. 
			 * Returns the base font size
			 * 
			 */
 			addEventListener:function(fn,obj,bScope) {
				aListeners[aListeners.length] = {
					fn: fn,
					obj: obj
				}
				return iBase;
			},
			/**
			 * performs the detection and fires textSizeChanged event
			 * @return the current font size
			 * @type {integer}
			 */
 			detect:function() {
 				return _detect();
 			},
 			/**
 			 * Returns the height of the control element
 			 * 
			 * @return the current height of control element
			 * @type {integer}
 			 */
 			getSize:function() {
	 				var iSize;
			 		return el.offsetHeight;
		 		
		 		
 			},
 			/**
 			 * Stops the detector
 			 */
 			stopDetector:function() {
				return _stopDetector();
			},
			/*
			 * Starts the detector
			 */
 			startDetector:function() {
				return _startDetector();
			}
 	}
 }();

TextResizeDetector.TARGET_ELEMENT_ID = 'doc';
TextResizeDetector.USER_INIT_FUNC = null;
// ------------------ textresizedetector.js ends here -------------------------
// ------------------- textresizeinit.js starts here --------------------------
/*
	detect the users font size and adjust the layout appropriately
*/
 	function init()  {
	   var iBase = TextResizeDetector.addEventListener(onFontResize,null);
	   var bodyTag = document.getElementById('wrapper');
	   if(bodyTag)  {
		   if (iBase>27)  {
				bodyTag.className='large-type';
			}
		}
	}
	//id of element to check for and insert control
	TextResizeDetector.TARGET_ELEMENT_ID = 'wrapper';
	//function to call once TextResizeDetector has init'd
	TextResizeDetector.USER_INIT_FUNC = init;
		function onFontResize(e,args) {
			var bodyTag = document.getElementById('wrapper');
			if(bodyTag){
				//27 is the last font size for the standard layout
				if (args[0].iSize>27)  {
					bodyTag.className='large-type';
				}
				if (args[0].iSize<26)
				{
					bodyTag.className='';
				}
			}
		}
// -------------------- textresizeinit.js ends here ---------------------------
// -------------------- togglingTabs.js starts here ---------------------------
addEvent(window, "load", tabs); 

function tabs()
{
	if(!document.getElementById('blogging-section')) return;
	
	document.getElementById('most-commented-entries').className = "active";
	
	var buttons=document.getElementById('blogging-section').getElementsByTagName('span');
	var bloggies=document.getElementById('blogging-section');
	
	for(var i=0; i<buttons.length; i++) {
		buttons[i].onclick= function (){
			var parent= this.parentNode
			if(this.id=="recent-entries") {
			
				this.className = "active";
				document.getElementById('most-commented-entries').className = "inactive";
			
				if(parent.getElementsByTagName('ul')[0].className.match(/\bhidden\b/)){
					toggleClass(parent);
					toggleClass(document.getElementById('most-commented-entries').parentNode);
				}
			} else {
				
				this.className = "active";
				document.getElementById('recent-entries').className = "inactive";
			
				if(parent.getElementsByTagName('ul')[0].className.match(/\bhidden\b/)){
					toggleClass(parent);
					toggleClass(document.getElementById('recent-entries').parentNode);
				}
		}
			
			function toggleClass(element){
						
				var currentClass=element.getElementsByTagName('ul')[0].className;
				if(currentClass.match(/\bvisible\b/)) currentClass=currentClass.replace(/visible/ , 'hidden');
				else if(currentClass.match(/\hidden\b/)) currentClass=currentClass.replace(/hidden/ , 'visible');	
				element.getElementsByTagName('ul')[0].className=currentClass;
			}

			
			
		}
	}
}
// -------------------- togglingTabs.js ends here ----------------------------





// -------------------- generic togglingTabs.js starts here ----------------------------

addEvent(window, "load", generictabs); 

function generictabs(activetab)
{
	if(!document.getElementById('tab-section')) return;
	
	document.getElementById('tab-default').className = "active";
	
	var buttons=document.getElementById('tab-section').getElementsByTagName('span');
	var bloggies=document.getElementById('tab-section');
	
	for(var i=0; i<buttons.length; i++) {
		buttons[i].onclick= function (){
			var parent= this.parentNode
			if(this.id=="tab-default") {
			
				this.className = "active";
				document.getElementById('tab-other').className = "inactive";
			
				if(parent.getElementsByTagName('ul')[0].className.match(/\bhidden\b/)){
					toggleClass(parent);
					toggleClass(document.getElementById('tab-other').parentNode);
				}
			} else {
				
				this.className = "active";
				document.getElementById('tab-default').className = "inactive";
			
				if(parent.getElementsByTagName('ul')[0].className.match(/\bhidden\b/)){
					toggleClass(parent);
					toggleClass(document.getElementById('tab-default').parentNode);
				}
		}
			
			function toggleClass(element){
						
				var currentClass=element.getElementsByTagName('ul')[0].className;
				if(currentClass.match(/\bvisible\b/)) currentClass=currentClass.replace(/visible/ , 'hidden');
				else if(currentClass.match(/\hidden\b/)) currentClass=currentClass.replace(/hidden/ , 'visible');	
				element.getElementsByTagName('ul')[0].className=currentClass;
			}

			
			
		}
	}
}

// -------------------- generic togglingTabs.js ends here ----------------------------
// ------------------- travel-mask-bg.js starts here --------------------------
/*@cc_on @*/
/*@if (@_jscript_version <= 5.6)
// The above conditional compilation for IE is equivalent to
// a conditional comment in HTML of 'if lte IE 6' 

addEvent(window, "load", maskImages);

function maskImages()  {
	var imageCollection=new Array();
	var count=0;
	if(document.getElementsByTagName('body')[0].className.match('commercial'))  {
		imageCollection[0]=document.getElementsByTagName('img');
	}
	else  {		
		var divs=document.getElementsByTagName('div');
		for(var i=0; i<divs.length; i++)  {
			if(divs[i].className.match(/\bcommercial\b/))  {
				
					imageCollection[count]=divs[i].getElementsByTagName('img');
					count++;
			}
		}		
	}

	var root=commonStaticRoot+'styles/wide/images/';
	var masks= Array('460x276-mask.png', '300x180-mask.png', '140x180-mask.png', '140x84-mask.png', '280x168-mask.png', '130x78-mask.png', '220x132-mask.png', '140x120-mask.png', '130x111-mask.png');
	var newImage,images, mask;
	
	
	for (var j=0; j<imageCollection.length; j++)  {
		images=imageCollection[j];
		for (var i=0; i< images.length; i++)  {
			newImage=false;
			if(!images[i].src.match(/-mask\.png$/)) {
                switch (Number(images[i].getAttribute('width')))  {
                    case 460:
                        newImage=document.createElement("div");
                        newImage.style.width="460px";
                        newImage.style.height="276px";
                        mask=root+masks[0];
                        break;
                    case 300:
                        newImage=document.createElement("div");
                        newImage.style.width="300px";
                        newImage.style.height="180px";
                        mask=root+masks[1];
                    
                        break;
                    case 140:
                        
                        if (images[i].getAttribute('height')==180)  {				
                                newImage=document.createElement("div");
                                newImage.style.width="140";
                                newImage.style.height="180px";
                                mask=root+masks[2];
                            }
                            else if(images[i].getAttribute('height')==84) {
                                newImage=document.createElement("div");
                                newImage.style.width="140";
                                newImage.style.height="84px";
                                mask=root+masks[3];
                            }
                             else if(images[i].getAttribute('height')==89) {
                                newImage=document.createElement("div");
                                newImage.style.width="140";
                                newImage.style.height="84px";
                                mask=root+masks[3];
                            }
                             else if(images[i].getAttribute('height')==120) {
                                newImage=document.createElement("div");
                                newImage.style.width="140";
                                newImage.style.height="120px";
                                mask=root+masks[7];
                            }
                        break;
                    case 280:
                        newImage=document.createElement("div");
                        newImage.style.width="280px";
                        newImage.style.height="168px";
                        mask=root+masks[4];                    
                        break;
                    case 130:
                        newImage=document.createElement("div");
                        newImage.style.width="130px";
                        if(images[i].getAttribute('height')==78) {
							newImage.style.height="78px";
							mask=root+masks[5];
                        }else{
                        	newImage.style.height="111px";
							mask=root+masks[7];
                        }
                    	
                        break;
                    case 220:
                        newImage=document.createElement("div");
                        newImage.style.width="220px";
                        newImage.style.height="132px";
                        mask=root+masks[6];
                        break;
                }
            }			
			if(newImage && images[i].parentNode.nodeName.match(/^a$|^div/i) && images[i].parentNode.lastChild.className!='mask')  {
				newImage.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+mask+"',sizingMethod='scale')";
				newImage.style.position="absolute";
				newImage.style.top="0";
				newImage.style.left="0";
				newImage.style.zIndex="100";
                images[i].parentNode.style.position='relative';
                images[i].parentNode.style.width='1px';
                images[i].parentNode.style.display='block';
				images[i].parentNode.appendChild(newImage);
			}
			
		}
	}


}
/*@end @*/
// -------------------- travel-mask-bg.js ends here ---------------------------
// -------------------- travel-mask.js starts here ----------------------------
/*@cc_on @*/
/*@if (@_jscript_version > 5.6 | !@_jscript)  // */
// The above conditional compilation for IE is equivalent to
// a conditional comment in HTML of 'if gt IE 6' or 'if !IE'

addEvent(window, "load", maskImages);

function maskImages()  {
	var imageCollection=new Array();
	var count=0;
	if(document.getElementsByTagName('body')[0].className.match('commercial'))  {
		imageCollection[0]=document.getElementsByTagName('img');
		
	}
	else  {		
		var divs=document.getElementsByTagName('div');
		for(var i=0; i<divs.length; i++)  {
			if(divs[i].className.match(/\bcommercial\b/))  {
					imageCollection[count]=divs[i].getElementsByTagName('img');
					count++;
			}
		}		
	}

	var root=commonStaticRoot+'styles/wide/images/';
	var masks= Array('460x276-mask.png', '300x180-mask.png', '140x180-mask.png', '140x84-mask.png', '280x168-mask.png', '130x78-mask.png', '220x132-mask.png', '140x120-mask.png', '130x111-mask.png');
	var newImage, images;
	
	for (var j=0; j<imageCollection.length; j++)  {
		images=imageCollection[j];
		for (var i=0; i< images.length; i+=2)  {
			newImage=false;
                switch (Number(images[i].getAttribute('width')))  {
                    case 460:
                        newImage=images[i].cloneNode(false);
                        newImage.setAttribute('src',root+masks[0]);
                        break;
                    case 300:
                        newImage=images[i].cloneNode(false);
                        newImage.setAttribute('src',root+masks[1]);
                        break;
                    case 140:
                     images[i].parentNode.style.width='140px';
                        if (images[i].getAttribute('height')==180)  {
                                newImage=images[i].cloneNode(false);
                                newImage.setAttribute('src',root+masks[2]);
                            }
                            else if(images[i].getAttribute('height')==84)  {
                                newImage=images[i].cloneNode(false);
                                newImage.setAttribute('src',root+masks[3]);
                            }
                            else if(images[i].getAttribute('height')==89)  {
                                newImage=images[i].cloneNode(false);
                                newImage.setAttribute('src',root+masks[3]);
                               
                            }
                            else if(images[i].getAttribute('height')==120)  {
                                newImage=images[i].cloneNode(false);
                                newImage.setAttribute('src',root+masks[7]);
                               
                            }
                        break;
                    case 280:
                        newImage=images[i].cloneNode(false);
                        newImage.setAttribute('src',root+masks[4]);
                        break;
                    case 130:
                        newImage=images[i].cloneNode(false);
                        if(images[i].getAttribute('height')==78) {
							newImage.setAttribute('src',root+masks[5]);
                        }else{
							newImage.setAttribute('src',root+masks[7]);
                        }
                        break;
                    case 220:
                        newImage=images[i].cloneNode(false);
                        newImage.setAttribute('src',root+masks[6]);
                        break;                     
                    
    			}
			if(newImage && images[i].parentNode.nodeName.match(/^a$|^div/i) && images[i].parentNode.lastChild.className!='mask') {
                images[i].parentNode.style.display='block';
                images[i].parentNode.style.position='relative';

                newImage.className='mask';
                images[i].parentNode.appendChild(newImage);
			}
			else  {
				i--;
			}
		}
	}


}
/*@end @*/
// --------------------- travel-mask.js ends here -----------------------------
// ------------------------ ufo.js starts here --------------------------------
/*	Unobtrusive Flash Objects (UFO) v3.21 <http://www.bobbyvandersluis.com/ufo/>
	Copyright 2005, 2006 Bobby van der Sluis
	This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/

var UFO = {
	req: ["movie", "width", "height", "majorversion", "build"],
	opt: ["play", "loop", "menu", "quality", "scale", "salign", "wmode", "bgcolor", "base", "flashvars", "devicefont", "allowscriptaccess", "seamlesstabbing", "allowfullscreen"],
	optAtt: ["id", "name", "align"],
	optExc: ["swliveconnect"],
	ximovie: "ufo.swf",
	xiwidth: "215",
	xiheight: "138",
	ua: navigator.userAgent.toLowerCase(),
	pluginType: "",
	fv: [0,0],
	foList: [],
		
	create: function(FO, id) {
		if (!UFO.uaHas("w3cdom") || UFO.uaHas("ieMac")) return;
		UFO.getFlashVersion();
		UFO.foList[id] = UFO.updateFO(FO);
		UFO.createCSS("#" + id, "visibility:hidden;");
		UFO.domLoad(id);
	},

	updateFO: function(FO) {
		if (typeof FO.xi != "undefined" && FO.xi == "true") {
			if (typeof FO.ximovie == "undefined") FO.ximovie = UFO.ximovie;
			if (typeof FO.xiwidth == "undefined") FO.xiwidth = UFO.xiwidth;
			if (typeof FO.xiheight == "undefined") FO.xiheight = UFO.xiheight;
		}
		FO.mainCalled = false;
		return FO;
	},

	domLoad: function(id) {
		var _t = setInterval(function() {
			if ((document.getElementsByTagName("body")[0] != null || document.body != null) && document.getElementById(id) != null) {
				UFO.main(id);
				clearInterval(_t);
			}
		}, 250);
		if (typeof document.addEventListener != "undefined") {
			document.addEventListener("DOMContentLoaded", function() { UFO.main(id); clearInterval(_t); } , null); // Gecko, Opera 9+
		}
	},

	main: function(id) {
		var _fo = UFO.foList[id];
		if (_fo.mainCalled) return;
		UFO.foList[id].mainCalled = true;
		document.getElementById(id).style.visibility = "hidden";
		if (UFO.hasRequired(id)) {
			if (UFO.hasFlashVersion(parseInt(_fo.majorversion, 10), parseInt(_fo.build, 10))) {
				if (typeof _fo.setcontainercss != "undefined" && _fo.setcontainercss == "true") UFO.setContainerCSS(id);
				UFO.writeSWF(id);
			}
			else if (_fo.xi == "true" && UFO.hasFlashVersion(6, 65)) {
				UFO.createDialog(id);
			}
		}
		document.getElementById(id).style.visibility = "visible";
	},
	
	createCSS: function(selector, declaration) {
		var _h = document.getElementsByTagName("head")[0]; 
		var _s = UFO.createElement("style");
		if (!UFO.uaHas("ieWin")) _s.appendChild(document.createTextNode(selector + " {" + declaration + "}")); // bugs in IE/Win
		_s.setAttribute("type", "text/css");
		_s.setAttribute("media", "screen"); 
		_h.appendChild(_s);
		if (UFO.uaHas("ieWin") && document.styleSheets && document.styleSheets.length > 0) {
			var _ls = document.styleSheets[document.styleSheets.length - 1];
			if (typeof _ls.addRule == "object") _ls.addRule(selector, declaration);
		}
	},
	
	setContainerCSS: function(id) {
		var _fo = UFO.foList[id];
		var _w = /%/.test(_fo.width) ? "" : "px";
		var _h = /%/.test(_fo.height) ? "" : "px";
		UFO.createCSS("#" + id, "width:" + _fo.width + _w +"; height:" + _fo.height + _h +";");
		if (_fo.width == "100%") {
			UFO.createCSS("body", "margin-left:0; margin-right:0; padding-left:0; padding-right:0;");
		}
		if (_fo.height == "100%") {
			UFO.createCSS("html", "height:100%; overflow:hidden;");
			UFO.createCSS("body", "margin-top:0; margin-bottom:0; padding-top:0; padding-bottom:0; height:100%;");
		}
	},

	createElement: function(el) {
		return (UFO.uaHas("xml") && typeof document.createElementNS != "undefined") ?  document.createElementNS("http://www.w3.org/1999/xhtml", el) : document.createElement(el);
	},

	createObjParam: function(el, aName, aValue) {
		var _p = UFO.createElement("param");
		_p.setAttribute("name", aName);	
		_p.setAttribute("value", aValue);
		el.appendChild(_p);
	},

	uaHas: function(ft) {
		var _u = UFO.ua;
		switch(ft) {
			case "w3cdom":
				return (typeof document.getElementById != "undefined" && typeof document.getElementsByTagName != "undefined" && (typeof document.createElement != "undefined" || typeof document.createElementNS != "undefined"));
			case "xml":
				var _m = document.getElementsByTagName("meta");
				var _l = _m.length;
				for (var i = 0; i < _l; i++) {
					if (/content-type/i.test(_m[i].getAttribute("http-equiv")) && /xml/i.test(_m[i].getAttribute("content"))) return true;
				}
				return false;
			case "ieMac":
				return /msie/.test(_u) && !/opera/.test(_u) && /mac/.test(_u);
			case "ieWin":
				return /msie/.test(_u) && !/opera/.test(_u) && /win/.test(_u);
			case "gecko":
				return /gecko/.test(_u) && !/applewebkit/.test(_u);
			case "opera":
				return /opera/.test(_u);
			case "safari":
				return /applewebkit/.test(_u);
			default:
				return false;
		}
	},
	
	getFlashVersion: function() {
		if (UFO.fv[0] != 0) return;  
		if (navigator.plugins && typeof navigator.plugins["Shockwave Flash"] == "object") {
			UFO.pluginType = "npapi";
			var _d = navigator.plugins["Shockwave Flash"].description;
			if (typeof _d != "undefined") {
				_d = _d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
				var _m = parseInt(_d.replace(/^(.*)\..*$/, "$1"), 10);
				var _r = /r/.test(_d) ? parseInt(_d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
				UFO.fv = [_m, _r];
			}
		}
		else if (window.ActiveXObject) {
			UFO.pluginType = "ax";
			try { // avoid fp 6 crashes
				var _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
			}
			catch(e) {
				try { 
					var _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
					UFO.fv = [6, 0];
					_a.AllowScriptAccess = "always"; // throws if fp < 6.47 
				}
				catch(e) {
					if (UFO.fv[0] == 6) return;
				}
				try {
					var _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
				}
				catch(e) {}
			}
			if (typeof _a == "object") {
				var _d = _a.GetVariable("$version"); // bugs in fp 6.21/6.23
				if (typeof _d != "undefined") {
					_d = _d.replace(/^\S+\s+(.*)$/, "$1").split(",");
					UFO.fv = [parseInt(_d[0], 10), parseInt(_d[2], 10)];
				}
			}
		}
	},

	hasRequired: function(id) {
		var _l = UFO.req.length;
		for (var i = 0; i < _l; i++) {
			if (typeof UFO.foList[id][UFO.req[i]] == "undefined") return false;
		}
		return true;
	},
	
	hasFlashVersion: function(major, release) {
		return (UFO.fv[0] > major || (UFO.fv[0] == major && UFO.fv[1] >= release)) ? true : false;
	},

	writeSWF: function(id) {
		var _fo = UFO.foList[id];
		var _e = document.getElementById(id);
		if (UFO.pluginType == "npapi") {
			if (UFO.uaHas("gecko") || UFO.uaHas("xml")) {
				while(_e.hasChildNodes()) {
					_e.removeChild(_e.firstChild);
				}
				var _obj = UFO.createElement("object");
				_obj.setAttribute("type", "application/x-shockwave-flash");
				_obj.setAttribute("data", _fo.movie);
				_obj.setAttribute("width", _fo.width);
				_obj.setAttribute("height", _fo.height);
				var _l = UFO.optAtt.length;
				for (var i = 0; i < _l; i++) {
					if (typeof _fo[UFO.optAtt[i]] != "undefined") _obj.setAttribute(UFO.optAtt[i], _fo[UFO.optAtt[i]]);
				}
				var _o = UFO.opt.concat(UFO.optExc);
				var _l = _o.length;
				for (var i = 0; i < _l; i++) {
					if (typeof _fo[_o[i]] != "undefined") UFO.createObjParam(_obj, _o[i], _fo[_o[i]]);
				}
				_e.appendChild(_obj);
			}
			else {
				var _emb = "";
				var _o = UFO.opt.concat(UFO.optAtt).concat(UFO.optExc);
				var _l = _o.length;
				for (var i = 0; i < _l; i++) {
					if (typeof _fo[_o[i]] != "undefined") _emb += ' ' + _o[i] + '="' + _fo[_o[i]] + '"';
				}
				_e.innerHTML = '<embed type="application/x-shockwave-flash" src="' + _fo.movie + '" width="' + _fo.width + '" height="' + _fo.height + '" pluginspage="http://www.macromedia.com/go/getflashplayer"' + _emb + '></embed>';
			}
		}
		else if (UFO.pluginType == "ax") {
			var _objAtt = "";
			var _l = UFO.optAtt.length;
			for (var i = 0; i < _l; i++) {
				if (typeof _fo[UFO.optAtt[i]] != "undefined") _objAtt += ' ' + UFO.optAtt[i] + '="' + _fo[UFO.optAtt[i]] + '"';
			}
			var _objPar = "";
			var _l = UFO.opt.length;
			for (var i = 0; i < _l; i++) {
				if (typeof _fo[UFO.opt[i]] != "undefined") _objPar += '<param name="' + UFO.opt[i] + '" value="' + _fo[UFO.opt[i]] + '" />';
			}
			var _p = window.location.protocol == "https:" ? "https:" : "http:";
			_e.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + _objAtt + ' width="' + _fo.width + '" height="' + _fo.height + '" codebase="' + _p + '//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + _fo.majorversion + ',0,' + _fo.build + ',0"><param name="movie" value="' + _fo.movie + '" />' + _objPar + '</object>';
		}
	},
		
	createDialog: function(id) {
		var _fo = UFO.foList[id];
		UFO.createCSS("html", "height:100%; overflow:hidden;");
		UFO.createCSS("body", "height:100%; overflow:hidden;");
		UFO.createCSS("#xi-con", "position:absolute; left:0; top:0; z-index:1000; width:100%; height:100%; background-color:#fff; filter:alpha(opacity:75); opacity:0.75;");
		UFO.createCSS("#xi-dia", "position:absolute; left:50%; top:50%; margin-left: -" + Math.round(parseInt(_fo.xiwidth, 10) / 2) + "px; margin-top: -" + Math.round(parseInt(_fo.xiheight, 10) / 2) + "px; width:" + _fo.xiwidth + "px; height:" + _fo.xiheight + "px;");
		var _b = document.getElementsByTagName("body")[0];
		var _c = UFO.createElement("div");
		_c.setAttribute("id", "xi-con");
		var _d = UFO.createElement("div");
		_d.setAttribute("id", "xi-dia");
		_c.appendChild(_d);
		_b.appendChild(_c);
		var _mmu = window.location;
		if (UFO.uaHas("xml") && UFO.uaHas("safari")) {
			var _mmd = document.getElementsByTagName("title")[0].firstChild.nodeValue = document.getElementsByTagName("title")[0].firstChild.nodeValue.slice(0, 47) + " - Flash Player Installation";
		}
		else {
			var _mmd = document.title = document.title.slice(0, 47) + " - Flash Player Installation";
		}
		var _mmp = UFO.pluginType == "ax" ? "ActiveX" : "PlugIn";
		var _uc = typeof _fo.xiurlcancel != "undefined" ? "&xiUrlCancel=" + _fo.xiurlcancel : "";
		var _uf = typeof _fo.xiurlfailed != "undefined" ? "&xiUrlFailed=" + _fo.xiurlfailed : "";
		UFO.foList["xi-dia"] = { movie:_fo.ximovie, width:_fo.xiwidth, height:_fo.xiheight, majorversion:"6", build:"65", flashvars:"MMredirectURL=" + _mmu + "&MMplayerType=" + _mmp + "&MMdoctitle=" + _mmd + _uc + _uf };
		UFO.writeSWF("xi-dia");
	},

	expressInstallCallback: function() {
		var _b = document.getElementsByTagName("body")[0];
		var _c = document.getElementById("xi-con");
		_b.removeChild(_c);
		UFO.createCSS("body", "height:auto; overflow:auto;");
		UFO.createCSS("html", "height:auto; overflow:auto;");
	},

	cleanupIELeaks: function() {
		var _o = document.getElementsByTagName("object");
		var _l = _o.length
		for (var i = 0; i < _l; i++) {
			_o[i].style.display = "none";
			for (var x in _o[i]) {
				if (typeof _o[i][x] == "function") {
					_o[i][x] = null;
				}
			}
		}
	}

};

if (typeof window.attachEvent != "undefined" && UFO.uaHas("ieWin")) {
	window.attachEvent("onunload", UFO.cleanupIELeaks);
}
// ------------------------- ufo.js ends here ---------------------------------
// ----------------------- viewer.js starts here ------------------------------
//addEvent(window, "load", viewer); 

function viewer ()  {
	if(document.getElementById('also-on'))  {
		var alsoOn=document.getElementById('also-on');
	}else{
		return;
	}
	
//collections links li's images so on	
		
		var links=alsoOn.getElementsByTagName('a');
		var lists=alsoOn.getElementsByTagName('ul');
		
		var timerLeft='';
		var timerRight='';
		var listItemWidth=159;
		var currentNumber=0;

		for (var i=0; i<lists.length;i++)  {
				if(lists[i].className.match('viewer')) var viewer=lists[i];
			}

		var listItems=viewer.getElementsByTagName('li');
			
		for (var i=0; i<links.length; i++)  {
				
				if(links[i].className.match('right'))  {
					links[i].onclick= function () {
						clearInterval(timerLeft);//don't do more than 1 animation otherwise things can become very fast
						changeHref(-1);//not working properly not an issue yet (maybe never?)
						moveLeft();
						requestItem(0, 'end') ;//where to put the replacement element
	
					return false;//don't follow the link
					}
						
				}	

				if(links[i].className.match('left'))  {
					links[i].onclick= function () {
						clearInterval(timerRight);//don't do more than 1 animation otherwise things can become very fast
						changeHref(1);//not working properly not an issue yet (maybe never?)
						moveRight();
						requestItem(listItems.length-1, 'start');//where to put the replacement element
						return false;	//don't follow the link
					}
					
				}
				
			}

//doesn't work not a problem for the demo, but later may be.
	function changeHref(direction)  {
		var maxNumber=7;
	
		for (var j=0; j<links.length; j++)  {
			if (links[j].className.match('left'))  {
				//fix an off by one error 
				listItems[listItems.length-1].style.marginRight='-1px';
				var oldHref=links[j].href;
				var currentNumber=oldHref.match(/[0-9]+/);
				currentNumber=currentNumber-direction;//no need to cast since - is always subtraction

				links[j].href='pic'+currentNumber+'.html';
				
			}
			
			 if (links[j].className.match('right'))  {
			 	
			 	var oldHref=links[j].href;
				var currentNumber=oldHref.match(/[0-9]+/);
				currentNumber= Number(currentNumber)+direction;//cast the value as a number otherwise + is the concatenation operator :(

				links[j].href='pic'+currentNumber+'.html';
				
			 }
			
		}
	}
	
	
		function moveLeft()  {
			
			
			viewer.removeChild(listItems[0]);//make space for the new item
			
			listItems[0].style.marginLeft=listItemWidth+'px';//fill the space with a margin
			timerLeft=setInterval(leftMargin,1);//reduce the margin repeatedly every 0.001 second
		
	
	}

		function moveRight()  {
			
			viewer.removeChild(listItems[listItems.length-1]);//make space for the item
			listItems[0].style.marginLeft=0;//don't need a left margin
			timerRight=setInterval(rightMargin,1);//slide in the new item
			
	}

function leftMargin ()  {
	if(timerRight) clearInterval(timerRight);//if we're already moving stop
	var currentMargin=listItems[0].style.marginLeft;//get the current left margin of the first li
	
	currentMargin=currentMargin.match(/[-0-9]+/);//get the numeric value
	
	if(currentMargin>=10)
		{
			var newMargin=currentMargin-8;//if we are far from the end position reduce the margin by 4px
		}else{
			var newMargin=currentMargin-1;//if we are close do so by 1px
		}
	listItems[0].style.marginLeft=newMargin+'px';//set the margin on the first li
	
	if(newMargin==-1) clearInterval(timerLeft);//if left margin==-1 stop moving
		
	
}

function rightMargin ()  {

	if(timerLeft) clearInterval(timerLeft);//if we are already moving stop
	var currentMargin=listItems[0].style.marginLeft;// get the current left margin of li one
	
	currentMargin=currentMargin.match(/[-0-9]+/);//capture the numeric value of the margin
	if (currentMargin<=-10)
	{
		var newMargin=Number(currentMargin)+8;//if we are far from the end position increase the margin by 4px
	}else{
		var newMargin=Number(currentMargin)+1;//if we are close do so by 1px
	}
	listItems[0].style.marginLeft=newMargin+'px';//set the margin on the first li
	
	if(newMargin==-1) clearInterval(timerRight);//if left margin==-1 stop moving
		
		
		
}


function requestItem(count, start)  {
	var newItem=listItems[count].cloneNode(true);//copy the appropriate list item count is a global and is set in click
	
	if (start=='end')  {
		var newLi=viewer.appendChild(newItem);//add the new li at the end of the list
		newLi.style.marginRight='-1px';//set the styling
		newLi.style.marginLeft='0';
	}else{
	
		newItem.style.marginLeft='-'+listItemWidth+'px';//set the new li's left margin to be minus the width of an li
		var newLi=viewer.insertBefore(newItem, listItems[0]);//add the new li at the start of the list
		listItems[0].style.marginLeft='-'+listItemWidth+'px';//set the left margin to an li's width
		newLi.style.marginRight='-1px';
		
	}
	
	
}
}
// ------------------------ viewer.js ends here -------------------------------
