function setLinks(){
	var links = document.getElementsByTagName('a');
	for (var i=0;i<links.length;i++){
	 	if(links[i].className == 'external'){
		links[i].onclick = function(){window.open(this.href,'','');return false}
		}else if(links[i].className == 'contact'){
	    links[i].onmouseover = function(){setContact(this.id);return false} 
		links[i].onfocus = function(){setContact(this.id);return false}
		}else if(links[i].className == 'archived_years'){
		links[i].onclick = function(){block(this.title);return false}
		}else if(links[i].className == 'ajax'){
		links[i].onclick = function(){show_user(this.href,this.rel);return false}	
		}
	}
} 
function setContact(adr) {
var obj = document.getElementById(adr);
	if (obj) {
		adr = (adr == 'w') ? 'webmaster' : 'info';
		var dmn = 'sevencolors.org';
		obj.href = 'mailto:' + adr + '@' + dmn;
	}
	return true;
}
function close_arch(){
var d = document.getElementsByTagName("dl");
for(var i=0;i<d.length;i++){
if(d[i].className == 'years_list')
d[i].style.display = 'none'; 
 }
}
var supported = (document.all || (document.getElementById && !window.opera));

function block(i){
	if(!supported)return;	//added by A.Bianchini
	var x = document.getElementById(i);
	with(x.style)
	{
	display == 'none' ? display = 'block' : display = 'none';
	}
	}
function go_home(){
var h = document.getElementById('header');
if(!h || window.location == "http://sevencolors.org/" || window.location == "http://sevencolors.org/index.php" || window.location == "http://sevencolors.org/index.htm" || window.location == "http://www.sevencolors.org/" || window.location == "http://www.sevencolors.org/index.php" || window.location == "http://www.sevencolors.org/index.htm") return;
h.setAttribute('title','web design - opinions - art - life');
h.onmouseover = function(){this.style.cursor = "pointer";return false};
h.onclick = function(){window.location = "http://sevencolors.org";return false};
}
function go_studies(){
var s = document.getElementById('studies_page_header');
if(!s) return;
s.onmouseover = function(){this.style.cursor = "pointer";return false};
s.onclick = function(){window.location = "http://sevencolors.org/index.htm#studies_div";return false};
}
function jsonFlickrApi(rsp){
	if (rsp.stat != 'ok') return;
	    var div = document.createElement('div');
		div.setAttribute('id','photos_wrapper');
		var div2 = document.createElement('div');
		div2.setAttribute('id','photos');
	for (var i=0; i<rsp.photos.photo.length; i++){
		var p = rsp.photos.photo[i];
		var a = document.createElement('a');
		a.setAttribute('href','http://www.flickr.com/photos/13067897@N00/'+p.id+'/');
		a.setAttribute('title',p.title);
		var img = document.createElement('img');
		img.setAttribute('src','http://farm'+p.farm+'.static.flickr.com/'+p.server+'/'+p.id+'_'+p.secret+'_t.jpg');
		img.setAttribute('alt',p.title);
		a.appendChild(img);											
		div2.appendChild(a);
	}
	var target = document.getElementById('badge');
	if(!target) return;
	div.appendChild(div2);
	target.appendChild(div);
}
 function call_flickr(){
    var newScript = document.createElement('script');
	newScript.setAttribute('src','http://api.flickr.com/services/rest/?method=flickr.people.getPublicPhotos&api_key=af7c02f8faf56ab8f8614b194a71f46b&user_id=13067897%40N00&per_page=8&page=1&format=json&callback=jsonFlickrApi');
	var obj = document.getElementById('write');
	if(!obj) return;
	obj.appendChild(newScript);
}
function show_user(str,dn)
{
if (str=="")
  {
  document.getElementById("post_cont").innerHTML="";
  return;
  }
  var bits = str.split("/");
  var perm = bits[3];
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("post_cont").innerHTML=xmlhttp.responseText;
	var ct = document.getElementById("cal_table");
	var fc = ct.firstChild;
	var td = fc.firstChild;
	//alert(td);
	for(i=0;i<td.children.length;i++){
		if(td.children[i].firstchild != ''){
			for(z=0;z<td.children[i].children.length;z++){
				if(td.children[i].children[z].nodeName == "A"){
				var l = td.children[i].children[z];
				var num = td.children[i].children[z].firstChild;
				if(dn == num.nodeValue){
				var pn = td.children[i].children[z].parentNode;
				var nn = document.createElement("h3");
				pn.replaceChild(nn,l);
				pn.setAttribute("id","cal_arr");
				pn.setAttribute("title","Current post");
				var sp = document.createElement("span");
				nn.appendChild(sp);
				sp.appendChild(num);
				sp.setAttribute("id","c_post");
				}
				 }else if(td.children[i].children[z].nodeName == "H3"){
				 var nh = td.children[i].children[z];
				 var pnn = nh.parentNode;
				 var hn = nh.firstChild;
				 if(hn.nodeType != 3){
					 var nt = hn.firstChild;
					 var ntt = nt.nodeValue;
					 var na = document.createElement("a");
					 pnn.removeAttribute("id");
					 pnn.removeAttribute("title");
					 pnn.replaceChild(na,nh);
					 na.setAttribute("class","ajax");
					 na.setAttribute("href","javascript:;");//HOW TO GET DI HREF ???
					 na.setAttribute("rel",ntt);
					 na.appendChild(nt);
				 }
				 
				 }
				}//for
			}
		}
	}
  }
xmlhttp.open("GET","functions/get_post.php?np="+perm,true);
xmlhttp.send();
}
window.onload = function(){setLinks();close_arch();go_home();go_studies();call_flickr();};
