function addEvent(obj, evType, fn){
	if(obj.addEventListener){
		obj.addEventListener(evType, fn, false); 
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent('on'+evType, fn);
		return r;
	} else {
		return false;
	}
}


function hideit(){
	$('loading').style.display 		= 'none';
}


function reportError(){
	alert('OoOps..I made a poopoo..Please try again!');
}

function flickrFetch(offset){
	if (offset>=1){
	
		$('loading').style.display = 'block';
		
		var myAjax = new ajax ('http://marios.tziortzis.com/photoblog/flickr.php', {
				postBody: 'offset='+offset+'&perpage=4',
				update: $('flickrsets'),
				onComplete: hideit,
				onFailure: reportError,
				evalScripts: true});
	} else {
		alert('There aren\'t any more photos in that direction!');
	}
}



function flickrGetImage(img,id,secret,title){
	$('loading').style.display = 'block';
	var myAjax = new ajax ('http://marios.tziortzis.com/photoblog/flickr.php', {
			postBody: 'action=getimage&image='+img+'&photo_id='+id+'&secret='+secret+'&title='+title,
			update: $('featured'),
			onFailure: reportError,
			evalScripts: true});
}


function getContent(page){
	$('loadingPage').style.display = 'block';
	var myAjax = new ajax ('http://marios.tziortzis.com/photoblog/content.php', {
			postBody: 'page='+page,
			update: $('navData'),
			onComplete: hideit,
			onFailure: reportError,
			evalScripts: true});
}


function showmore(){
	obj = $('moreAboutMe');
	if (obj.style.display=='none'){
		obj.style.display = 'block';
		$('author_text').style.color = "#000";
		$('author_text').style.width = "217px";
		$('author_text').style.backgroundImage = "url(http://marios.tziortzis.com/photoblog/img/bgt.gif)";
		$('author_text').style.backgroundRepeat = "no-repeat";
	} else {
		obj.style.display='none';
		$('author_text').style.background = "none";
		$('author_text').style.color = '#fff'; //"#aeabab";
	}
}


function toggleDIV(el){
	var div = $(el);
	if (div.style.display == 'block'){
		div.style.display = 'none';
	} else {
		div.style.display = 'block';
	}
}

function checkDiv(el){
	var div = $(el);
	
}

function fade(value){
	if (document.all){
		$('featuredImg').style.filter = 'alpha(opacity='+ value +')';
	} else {
		$('featuredImg').style.opacity = value/100;
	}
	$('moredetails').style.display = 'none';
}


function checkLoaded(ft){
	if (document.images['featuredImg'].complete){
		$('moredetails').style.display = 'block';
		$('loading').style.display = 'none';
		if (!ft){
			//$('featured').innerHTML = $('featuredR').innerHTML;
		}
	} else {
		$('moredetails').style.display = 'none';
		$('loading').style.display = 'block';
	}
}

window.onload = function (){
	flickrFetch(1);
}