function swapMainImage(id, image){

	

	$('mainImage'+id).hide();

	$('mainImage'+id).src='pics/'+blogID+'/'+id+'/'+image;

	$('mainImage'+id).appear();

	

}



function addComment(id){

	var j= 'addComment';

	var name = $('commentor'+id).value;

	var body = $('comment'+id).value;

    if (name==""){

		Alert('Please tell us your name');

	}

	else{

	$('commentForm'+id).innerHTML = "<br /> <br />Sending...";

    

	var myAjax = new Ajax.Updater('commentsSpan'+id, 'blogAdmin/jobs.php' ,

				{parameters:{j:j, id:id, name:name, body:body, blogID:blogID} ,

				asynchronous:true,

				onComplete:function(t){

								//$('commentsSpan'+id).innerHTML = t.responseText;

								$('commentsCount'+id).innerHTML ++;

							},

				method:'post'}

				);

	}

}



function ritsLogin(p){

	var url = 'blogAdmin/jobs.php';

    var pars = 'j=login&p='+p;

	var target = 'loginResult';

	$('loginLoading').show();

    var myAjax = new Ajax.Updater(target, url, {method: 'get', parameters: pars,evalScripts:true });

	

}





function runItems(i){

	if (i==ec){

		m=(65*ec)+1;//alert(m);

		$('itemscroll').style.top='65px';

		i=0;

	}

	new Effect.Move ('itemscroll', { x: 0, y: -65, mode: 'relative'});

	i++;

	if (timerRunning){timerID = setTimeout('runItems('+i+');',timeout);}

}











function openLink(URI){

	win = window.open(URI,"secWin","width=600,height=600,left=100,scrollbars=yes,resiz able=yes,location=yes");

	win.focus;

}

	 

function doSearch(val){

	if (val.length<3){

		$('searchresults').style.display='none';

	}

	//alert(val.length+val);

	if (val.length >= 3){

		new Ajax.Updater('searchresults', 'searchs.php?ajax=1&mode=quicksearch&search=' + val,{onComplete:function(){ 

					Effect.Appear('searchresults', {to:0.9,duration:0.2});

					}, asynchronous:true});

		$('searchresults').style.zIndex='5000';

		}

}



Event.observe(window, 'load', function() {

  $$('a[href^=#]:not([href=#])').each(function(element) {

    element.observe('click', function(event) {

      new Effect.ScrollTo(this.hash.substr(1), {duration:2});

      Event.stop(event);

    }.bindAsEventListener(element))

  })

})