// JavaScript Document
$ = new Function('x', 'return document.getElementById(x)');
var IE = (navigator.appName.indexOf("Microsoft"))==-1?false:true;

var dropdown_timer = null;
var menu_array = new Array();

//****Getting Started
var gs_history = new Array();
var gs_n = 0;

function gsSwapDiv(newone) {
	var displayone = document.getElementById('gs_display');
	newone = document.getElementById(newone);
	
	gs_history.push(displayone.innerHTML);
	
	if( gs_history.length <= 0 ) {
		document.getElementById('gs_back').style.color = "#666666";
		document.getElementById('gs_back').style.textDecoration = "none";
	} else {
		document.getElementById('gs_back').style.color = "#0000cc";
		document.getElementById('gs_back').style.textDecoration = "underline";
	}
	
	displayone.innerHTML = newone.innerHTML
}

function gsHistory() {
	if( gs_history.length > 0 ) {
		var displayone = document.getElementById('gs_display');
		displayone.innerHTML = gs_history.pop();
		if( gs_history.length <= 0 ) {
		document.getElementById('gs_back').style.color = "#666666";
		document.getElementById('gs_back').style.textDecoration = "none";
		} else {
		document.getElementById('gs_back').style.color = "#0000cc";
		document.getElementById('gs_back').style.textDecoration = "underline";
		}
		
	}
}
//end getting started

function dropdown_over(id) {
	clear_all_dropdowns(id);
	window.clearTimeout(dropdown_timer);
	$(id).style.display = 'block';
}

function dropdown_out(id) {
	dropdown_timer = window.setTimeout("clear_all_dropdowns('"+id+"');",700);
}

function clear_all_dropdowns(id) {
	var found = false;
	for( var i=0; i<menu_array.length; i++) {
		if( menu_array[i] == id) found = true;
	}
	if( found == false) menu_array.push(id);
	
	for( var i=0; i<menu_array.length; i++) {
		$(menu_array[i]).style.display = 'none';
	}
}

var risknav = {
	nav: null,
	id:null,
	loc: 0,
	last:null,
	nav_order: new Array(),
	risk_nav_count: 0,
	
	make: function(id) {
		this.nav = $(id);
		this.id = id;
	
		//get links and add onclicks to the parent items
		var links = this.nav.getElementsByTagName("a");
		this.last = readCookie("risknavlast");
		
		for( var i=1; i<links.length; i++) {
			var daddy = links[i].parentNode;
			var ul = daddy.getElementsByTagName("ul");
			if(ul.length == 1) { // if <li> has one <ul>
				this.attachevent(links[i]);
			}
		}
	
		this.order();
		
		var cookie_loc = readCookie("risknavloc");
		

		if(cookie_loc == null) {
			this.makefirst();
		} else {
			this.reorder(cookie_loc*1);
		}
	},
	
	attachevent: function(obj) {
		var ul = obj.parentNode.getElementsByTagName("ul")[0];
	
		obj.id = "risklink-"+this.risk_nav_count++;
		obj.href = "javascript:risknav.toggle(\""+obj.id+"\")";
		if( obj.parentNode.className == "active") {
			ul.style.display = "block";
		} else {
			/*keeps last option opened
			if(""+obj.innerHTML == ""+this.last){
				 ul.style.display = "block";
			}
			else { ul.style.display = "none";
			}
			*/
		}
	},
	
	order: function() {
		this.nav = $(this.id);
		var navul = this.nav.getElementsByTagName("ul")[0];
		//var navul = $(this.id).getElementsByTagName("ul")[0];
		
		this.nav_order = new Array();
		
		for( var i=0; i<navul.childNodes.length; i++) {
	
			if( (""+navul.childNodes[i].nodeName).toLowerCase() == "li") {
				this.nav_order.push(navul.childNodes[i]);
			}
		}
	},
	
	makefirst: function() {
		
		if( this.nav_order[0].getElementsByTagName("ul")[0] ) {//if has submenus
			this.nav_order[0].className = "active";
			this.nav_order[0].getElementsByTagName("ul")[0].style.display = "block";
		} else {
			this.nav_order[0].className = "activenone";
		}
	},
	
	reorder: function(n) {
		this.order();
		var ul = this.nav_order[0].parentNode; //the <ul> parent of the <li>
		
		this.nav_order[0].className = "";//make first one inactive (as its moving)
		
		//if it has a child, set display to none
		if(this.nav_order[0].getElementsByTagName("ul")[0] ) this.nav_order[0].getElementsByTagName("ul")[0].style.display = "none";
		
		this.loc += n;
		this.createcookie();
		
		//begin while loop
		while( n != 0 ) {
			var first = this.nav_order[0];
			
			var last = this.nav_order[this.nav_order.length-1];
			
			if( n > 0) {//move up
				ul.appendChild(first);
				n--;
				//this.loc++;
			} else if( n < 0 ) {//move down
				//ul.removeChild(last); //dont need, last is a pointer
				ul.insertBefore(last, this.nav_order[0]);
				n++;
				//this.loc--;
			} else {//dont move at all
			}
			
			this.order();
		}
		
		//end while loop
		this.makefirst();
		$(this.id).innerHTML = this.nav.innerHTML;
	},
	
	toggle: function(id) {
		var ul = $(id).parentNode.getElementsByTagName("ul")[0];
		
		if( ul.style.display == "block") {
			ul.style.display = "none";
		} else {
			ul.style.display = "block";
			createCookie("risknavlast",""+$(id).innerHTML,1);
		}
	},
	
	openbyname: function(nama) {
		var ul = $(this.id).getElementsByTagName("ul")[0];
		
		for( var i=0; i< ul.childNodes.length; i++) {
			if( ul.childNodes[i].hasChildNodes() ) {
				var who = (ul.childNodes[i]);
				who = who.getElementsByTagName("a");
				if(who) {
					var whoname = ""+who[0].innerHTML;
					if(whoname == nama) {
						$(who[0].id).parentNode.getElementsByTagName("ul")[0].style.display = "block";
					}
				}
			}
		}
	},
	
	createcookie: function() {
		var mod = Math.floor((this.loc*1)/this.nav_order.length);
		this.loc -= mod*this.nav_order.length
		
		createCookie("risknavloc",this.loc,1365);
	}
}

var quicklinks = {
	maxlinks: 5,
	expire:1365,
	links: readCookie("quicklinks"),
	id:null,
	
	addlink: function(name,url) {
		this.links = readCookie("quicklinks");
		if( name == null ) name = document.title;
		if( url == null ) url = document.location;
		
		if( this.links == null) var temp = new Array();
		else var temp = this.links.split("|");
		
		var pieces = new Array();
		
		for( var i=0; i<temp.length; i+=2) {
			if(temp[i+1] != url) pieces.push( temp[i]+"|"+temp[i+1] );
		}
		
		if( pieces.length >= this.maxlinks ) {//over maxlinks amount
			tooltip.text("Five is the maximum number of Quick Pages, please delete one from the list.");
			setTimeout("tooltip.hidenow()",3000);
			return;
		}
		pieces.push(name+"|"+url);
		pieces.sort();
		var complete = pieces[0];
		
		for( var i=1; i<(pieces.length); i++) {
			complete += "|" + pieces[i];
		}

		createCookie("quicklinks",complete,this.expire);
		if(this.id != null) this.writelinks(this.id);
	},
	
	getlinks: function() {//returns the html ready to be put in an html element
		this.links = readCookie("quicklinks"); 
		var linkarray = new Array();
		try{
			var pieces = this.links.split("|");
		} catch(e){
			return linkarray;
		}
		
		for( var i = 0; i<pieces.length; i+=2) {
			linkarray.push("<div><a href=\""+pieces[i+1]+"\" onmouseover='dropdown_over(\""+this.id+"\")' onmouseout='dropdown_out(\""+this.id+"\")'>"+pieces[i]+"</a><a href=\"javascript:quicklinks.deletelink('"+pieces[i+1]+"')\" class=\"remove\"  onmouseover='dropdown_over(\""+this.id+"\")' onmouseout='dropdown_out(\""+this.id+"\")'>x</a></div>");
		}
		
		return linkarray;
	},
	
	writelinks: function(id) {
		this.id = id;
		var element = document.getElementById(id);
		var linkarray = this.getlinks();
		
		if(this.getlinks().length <= 0) {//no quicklinks, return false (or default link set)
			element.innerHTML = "<a href='/about/contacts/' onmouseover='dropdown_over(\""+this.id+"\")' onmouseout='dropdown_out(\""+this.id+"\")' style='width:100%; border-bottom:1px solid #ffffff'>Contacts</a>";
			element.innerHTML += "<a href='/help/help.aspx' onmouseover='dropdown_over(\""+this.id+"\")' onmouseout='dropdown_out(\""+this.id+"\")' style='width:100%; border-bottom:1px solid #ffffff'>Help</a>";
			element.innerHTML += "<a href='/library/' onmouseover='dropdown_over(\""+this.id+"\")' onmouseout='dropdown_out(\""+this.id+"\")' style='width:100%; border-bottom:1px solid #ffffff'>Fund Member Library</a>";
			
		} else {
			element.innerHTML = linkarray[0];
			for( var i=1; i<linkarray.length; i++) {
				element.innerHTML += "<br/>" + linkarray[i];
			}
		}
	},
	
	deletelink: function(url) {
		
		if( url == null ) url = document.location;
		else url = "http://"+escape(url.split("http://")[1]);
		
		this.links = readCookie("quicklinks");
		
		if( this.links.length >0 ) { //if there are no quicklinks
			var goahead = confirm("Are you sure you want to remove this from your Quick Pages?");
			if( ! goahead ) return;
		} else return;

		var temp = this.links.split("|");
		var pieces = new Array();
		
		//cycle through temp (pieces of quicklinks) and rebuild quicklinks minus the deleted one
		for( var i=0; i<temp.length; i+=2) {
			if( temp[i+1].indexOf(url) == -1) {
				pieces.push( temp[i]+"|"+temp[i+1] );
			}
		}
		
		if(pieces.length <= 0) { //no more cookies. deleted last one
				this.deletelinks();
				return;
		}
		pieces.sort();
		
		//rebuild the complete cookie ready to be set
		var complete = pieces[0];
		for( var i=1; i<(pieces.length); i++) {
			complete += "|" + pieces[i];
		}
		//set cookie
		createCookie("quicklinks",complete,this.expire);
		//if the id is defined, write it
		if(this.id != null) this.writelinks(this.id);
	},
	
	deletelinks: function() {
		deleteCookie("quicklinks");
		if(this.id != null) this.writelinks(this.id);
	}
}
//*******************Font Resizer
var fontsizer = {
	 id: "",
	 cookie: "RMFFontSize",
	 base: null,
	 
	 psize:0,
	 lisize:0,
	 h1size:12,
	 h2size:2,
	 h3size:0,
 
	 start: function(id) {
		  this.id = id;
		  
		 
		  this.base = readCookie(this.cookie);
		  
		  if( this.base == null ) {
		   this.base = "12";
		   createCookie(this.cookie, ""+this.base, 1365);
		  
		  } else {
		   this.absresize(this.base);
		  }
	 },
 
 absresize: function(n) {
	  var elem = $(this.id);
	  n = parseInt(n);
	  
	  var ps = elem.getElementsByTagName("p");
	  var lis = elem.getElementsByTagName("li");
	  var h1s = elem.getElementsByTagName("h1");
	  var h2s = elem.getElementsByTagName("h2");
	  var h3s = elem.getElementsByTagName("h3");
	  
	  
	  
	  this.resizer(ps, n+this.psize);
	  this.resizer(lis, n+this.lisize);
	  this.resizer(h1s, n+this.h1size);
	  this.resizer(h2s, n+this.h2size);
	  this.resizer(h3s, n+this.h3size);
 },
 
 resize: function(n) {
	  
	  var elem = $(this.id);
	  
	  this.base =parseInt(this.base)+ n;
	  
	  if( this.base >18 ) this.base = 18;
	  if( this.base < 8 ) this.base = 8;
	  
	  createCookie(this.cookie, ""+this.base, 1365);
	  
	  var ps = elem.getElementsByTagName("p");
	  var lis = elem.getElementsByTagName("li");
	  var h1s = elem.getElementsByTagName("h1");
	  var h2s = elem.getElementsByTagName("h2");
	  var h3s = elem.getElementsByTagName("h3");
	  
	  this.resizer(ps, parseInt(this.psize) + parseInt(this.base));
	  this.resizer(lis, parseInt(this.lisize) + parseInt(this.base));
	  this.resizer(h1s, parseInt(this.h1size) + parseInt(this.base));
	  this.resizer(h2s, parseInt(this.h2size) + parseInt(this.base));
	  this.resizer(h3s, parseInt(this.h3size) + parseInt(this.base));
 },
 
 resizer: function(elems,size) {
	 
	  for( var i=0; i<elems.length; i++) {
	   elems[i].style.fontSize = size+"px";
	  }
 }
}
//****************Begin cookie manager functions
function createCookie(name,value,days) {
	var expires = new Date();
	expires.setTime(expires.getTime()+days*60*60*24*1000);
	expires = expires.toGMTString();
	
	var cookietxt = name+"="+escape(value)+"; expires="+expires+"; path=/;";
	document.cookie = cookietxt;
	return cookietxt;
}

function deleteCookie(name) {
	createCookie(name,"",-1);
}

function readCookie(name) {
	var cookie = document.cookie.split(';');
	var query = name+"=";
	
	for(var i=0; i<cookie.length; i++) {
		var piece = cookie[i];
		while(piece.charAt(0) == ' ') piece = piece.substring(1,piece.length);
		if( piece.indexOf(query) != -1) {
			var value = piece.substring(query.length,piece.length);
			return unescape(value);
		};
	}
	
	return null;
	
}

// breadcrumbs
//global xmphttp request for breadcrumbs
breadcrumbxmlhttp = false

function makeBreadcrumbs() {
	
	var breadcrumburl = "/sitetree.xml";
	if(! $("breadcrumbs") ) return false;
	
	if( window.ActiveXObject ) breadcrumbxmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	else breadcrumbxmlhttp = new XMLHttpRequest();
	breadcrumbxmlhttp.open("GET",breadcrumburl,true)
	breadcrumbxmlhttp.onreadystatechange = crumb_handler;
	breadcrumbxmlhttp.send(null);

}

function crumb_handler() {
	if( breadcrumbxmlhttp.readyState ==4 && breadcrumbxmlhttp.status == 200) {
		$("breadcrumbs").innerHTML = "...";
		//root xml doc
		var xmldoc = breadcrumbxmlhttp.responseXML;
		
		//array of folders (still contains server name and filename)
		//modify url if from CMS first
		var cmsurl = (""+document.location);
		var folders = "";
		
		if( cmsurl.indexOf("cms_TASBRMF/") != -1 ) {
			cmsurl = cmsurl.split("cms_TASBRMF/")[1];
		} else {
			cmsurl = (cmsurl).split("http://")[1];
		}
	
		//finally breaky into folders now that all the extra is gone
		folders = cmsurl.split("/");
		//remove the filename (and save it)
		var filename = folders.pop().split(".")[0];
		//bye bye server name
		folders.shift();
		
		//if the filename is index then the section name is not highlighted, else push filename back to folders
		if( filename == "index" || filename == "") {
		} else {
			folders.push(filename);
		}
		
		//the breadcrumb array,
		var crumbs = new Array();;
		//the current node 
		
		var node = xmldoc.getElementsByTagName("root")[0];
		
		//a copy of the folder array
		var copy = new Array();
		//can't actually force a copy in javascript so gotta do it the old fashioned way
		for( var i=0; i<folders.length; i++) {
			copy.push(folders[i]);
		}
		//the url of the crumb
		var url = "";
		var openname = false;
		//spider through the xml file using folders, picking up breadcrumbs
		for( var i=0; i<folders.length; i++) {
			node = find_node(node,folders[i]);
			if( node ) {
				var name = node.getAttribute("title");
				if (!openname) openname = ""+name;
				url += "/"+copy.shift();
				if( i != folders.length-1) {
					crumbs.push("<a href='"+url+"'>"+name+"</a>");
				} else {//last breadcrumb
					crumbs.push(name);
				}
			}
		}
		//write them crumbs
		risknav.openbyname(openname);
		$("breadcrumbs").innerHTML = crumbs.join(" > ");
	}
}

function find_node(root,nodename) {

	if( root ) {
		for( var i=0; i<root.childNodes.length; i++) {
			if(root.childNodes[i].nodeType != 3) {
				
				if((""+root.childNodes[i].getAttribute("name")) == nodename) {
					return root.childNodes[i];
				}
			}
		}
	}
	
	return false;
}

function openSubWin(strURL, pixW, pixH) {
    strLocation = strURL;
    strWHandle = "tasbrmfSubWin";
    strProps = "resizable=no,scrollbars=1,toolbar=no,location=no,directories=no,status=no,menubar=no,width=" + pixW + ",height=" + pixH + ",top=10,left=10";
    window.open(strLocation, strWHandle, strProps); 
}

var AvantGarde = {
	classname:"avant-garde",
	
	start: function() {
		var bodytag = document.getElementsByTagName("body")[0];
		
		var tables = bodytag.getElementsByTagName("table");
		
		for(var i=0; i<tables.length; i++) {
			if( tables[i].className == this.classname ) {
				//adjust the header
				var ths = tables[i].rows[0].getElementsByTagName("th");
				if(ths.length > 0) {
					ths[0].className = "tl";
					ths[ths.length-1].className = "tr";
					
					var lastrow = document.createElement("tr");
					lastrow.className = "lastrow";
					var lefttd = document.createElement("td");
					lefttd.innerHTML="&nbsp;";
					lefttd.colSpan = ths.length-1;
					lefttd.className = "bl";
					
					var righttd = document.createElement("td");
					righttd.innerHTML="&nbsp;";
					righttd.className = "br";
					
					lastrow.appendChild(lefttd);
					lastrow.appendChild(righttd);
					
					tables[i].appendChild(lastrow);
				}
				
			}
		}
	}
}

function getDate()
{
    var curdate = new Date()
    var year = curdate.getYear()
    document.write(year)
}
//Flash Fix
var bo_ns_id = 0;
function startIeFix(){  
    if(isIE()){    
     document.write('<div style="display: none;" id="bo_ns_id_' + bo_ns_id + '">');  
    }
}

function endIeFix(){  
    if(isIE()){    
        document.write('</div>');    
        var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++);    
        if(theObject.firstChild.data){      
            theObject.firstChild.removeAttribute('data');    
        } 
       
        var theParams = theObject.getElementsByTagName("param");    
        var theParamsLength = theParams.length;  
          
        for (var j = 0; j < theParamsLength; j++) {      
            if(theParams[j].name.toLowerCase() == 'flashvars'){        
                var theFlashVars = theParams[j].value;      
            }    
        }  
      
        var theInnnerHTML = theObject.innerHTML;    
        var re = /<param name="FlashVars" value="">/ig;    
        theInnnerHTML = theInnnerHTML.replace(re, "<param name=\"FlashVars\" value=\"" + theFlashVars + "\">");    
        theObject.outerHTML = theInnnerHTML;  
        //alert(theInnnerHTML);
    }
}
function isIE(){ 

    var strBrwsr = navigator.userAgent.toLowerCase();  
    if(strBrwsr.indexOf("msie") > -1 && strBrwsr.indexOf("mac") < 0){   
        return true;  
    }
    else
    {    
        return false;  
    }
}
//End Flash Fix
var photos = {
	display:2,
	width:160,
	total:false,
	IE:(navigator.appName.indexOf('Microsoft'))==-1?false:true,
	elements: new Array(),
	
	
	clicky: function(url,alt) {
		tooltip.toggle("tooltip.text('<div style=\"text-align:center; clear:both;\"><img src=\""+url+"\" style=\"margin:0 auto; padding:0 0 5px 0\" /><br/>"+alt+"</div>')");
		tooltip.setWidthAuto();
	},
	
	add: function(img) {
		this.image.push(img);
	},
	
	make: function(id) {
	},
	
	move: function(clicky, m) {
		var parent = clicky.parentNode;
		var id = parent.parentNode.getAttribute("id");
		var outter = parent.getElementsByTagName("div")[0];
		var inner = outter.getElementsByTagName("div")[0];
		
		//boot functionality
		if( this.elements[id].total == false) {
			this.elements[id].total = inner.getElementsByTagName('a').length;
			this.elements[id].maxleft = (this.elements[id].total-this.display)*(this.width)*(-1);
			inner.style.width = (this.elements[id].total*this.width)+"px";
			
		}
		
		//end boot:: Start auto quit if's
		
		if(this.elements[id].sliding!=false) return;
		if(this.elements[id].left+m < this.elements[id].maxleft) {
			
			m = this.elements[id].maxleft;
			
			if(this.elements[id].left == this.elements[id].maxleft) return;
		}
		if(this.elements[id].left+m>0) {
			m = 0 - this.elements[id].left;
			if(this.elements[id].left==0) return;
		}
		
		//left arrow
		var leftarrow = parent.getElementsByTagName("a")[0];
		if(this.elements[id].left+m > -1*this.width) {
			if(this.IE) leftarrow.style.filter = "alpha(opacity=30)";
			else leftarrow.style.opacity = ".3";
		} else {
			if(this.IE) leftarrow.style.filter = "alpha(opacity=100)";
			else leftarrow.style.opacity = "1";
		}
		 
		//right arrow
		var rightarrow = parent.getElementsByTagName("a")[1];
		
		if(this.elements[id].left+m < this.elements[id].maxleft + this.width) {
			if(this.IE) rightarrow.style.filter = "alpha(opacity=30)";
			else rightarrow.style.opacity = ".3";

		} else {
			if(this.IE) rightarrow.style.filter = "alpha(opacity=100)";
			else rightarrow.style.opacity = "1";
		}
		
		this.elements[id].slideleft += m;
		
		this.elements[id].sliding = inner;
		this.slide(id);
		
	},
	
	slide: function(id) {
		var thisslide = this.elements[id].slideleft;
		
		
		if( Math.abs(this.elements[id].slideleft) > 9) {
			thisslide = Math.floor(this.elements[id].slideleft*.10);
		} else {
			thisslide = thisslide/Math.abs(thisslide);
		}
		
		this.elements[id].slideleft -= thisslide;
		
		this.elements[id].left += thisslide;
		this.elements[id].sliding.style.left = this.elements[id].left+"px";
		
		if(this.elements[id].slideleft == 0 ) {
			window.clearTimeout(this.elements[id].timer);
			
			this.elements[id].sliding = false;
			
			
		} else {
			this.elements[id].timer = window.setTimeout("photos.slide('"+id+"')",20)
		}
	},
	
	goright: function() {
		var el = document.getElementById('moving');
	}
}

function xmldata(url,http) {
	this.url = url;
	this.http = http;
}

var pgallery = {
	loading: new Array(),
	
	
	load: function(url) {
		document.write( "<div id=\""+url+"\"></div>");	
		var xmlhttp = false;
		
		if(window.ActiveXObject) {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} else if( window.XMLHttpRequest ) {
			xmlhttp = new XMLHttpRequest();
		}
		
		if(xmlhttp) {
			xmlhttp.onreadystatechange = pgallery.handler;
			xmlhttp.open("GET", url, true);
			this.loading.push(new xmldata(url,xmlhttp));
			xmlhttp.send(null);
		}
	},
	
	handler: function() {
		for( var i=0; i<pgallery.loading.length; i++) {
			if( pgallery.loading[i].http.readyState==4) {
			 if(document.getElementById(pgallery.loading[i].url)){
				var div = document.createElement("div");
				var txt = pgallery.loading[i].http.responseText;
				var url = pgallery.loading[i].url;
				div.innerHTML = txt;
				var images = div.getElementsByTagName("img");
				
				var img_left = '/images/pgallery_arrow_l.gif';
				var img_right = '/images/pgallery_arrow_r.gif';
				if((""+document.location.host).toLowerCase() == "cms") {
					var cmsurl = "/servlet/nexus/preview/cms_TASBRMF/tasbrmfroot";
					img_left = cmsurl + img_left;
					img_right = cmsurl+ img_right;
				}
				
				var code = "<div class='pgallery' style='width:350px;'>";
				code += "<a href='javascript:void(0)' onclick='photos.move(this,320);' class='arrows' style='opacity:.3; filter:alpha(opacity=30); left:3px'><img src='"+img_left+"' alt='Left' border='0' /></a>";
				code += "<a href='javascript:void(0)' class='arrows' onclick='photos.move(this,-320);' style='left:340px;z-index:100;top:3px'><img src='"+img_right+"' alt='Right' border='0'/></a>";
				code += "<div class='pgalleryFrameOutter'><div class='pgalleryFrameInner'>";
				for( var j=0; j<images.length; j++) {
					var imgURL = images[j].getAttribute("src");
					var imgThumb = imgURL;
					if(images[j].getAttribute("name")) {
						imgThumb = imgURL.split("/");
						imgThumb.pop();
						imgThumb.push( images[j].getAttribute("name"));
						imgThumb = imgThumb.join("/");
					}
					code += "<a href='javascript:void(0)' onclick='photos.clicky(\""+imgURL+"\",\""+images[j].getAttribute("alt")+"\")' class='thumb'><img src='"+imgThumb+"' /></a>";
				}
				code += "</div></div>";
				
				code += "<div style='clear:both'></div></div>";
				
				document.getElementById(url).innerHTML = code;
				
				photos.elements[url] = {left:0, maxleft:-0, sliding: false, slideleft: 0, timer: false, total: false};
			  } else {
			  	
			  }
				pgallery.loading.splice(i,1);
				
				
			}
		}
	}
}