/**
 *
 */
showing = false;

/**
 * easier access to elements
 **/
function getel(obj_id){
	return document.getElementById(obj_id);
}

function showshared(){
	getel('mostread').style.display='none';
	getel('mostshared').style.display='block';
	getel('sharelink').style.textDecoration='underline';
	getel('readlink').style.textDecoration='none';
}

function showread(){
	getel('mostshared').style.display='none';
	getel('mostread').style.display='block';
	getel('readlink').style.textDecoration='underline';
	getel('sharelink').style.textDecoration='none';
}

function showold(){
	getel('oldtribe').style.display='block';
}

/* article admin */
function showhead(){
	if(edited == false){
		getel('headline').value = '';
		getel('headline').style.color='333';
	} else {}
	edited = true;
}
function showbody(){
	if(editing == false){
		getel('body').innerHTML = '';
		getel('body').style.color='333';
	} else {}
	editing = true;
}
function showtitle(){
	if(edited == false){
		getel('itemtitle').value = '';
		getel('itemtitle').style.color='333';
	} else {}
	edited = true;
}

function showhelpbox(){
	if(showhelp == 'visible'){
		getel('adminhelp').style.display='none';
		showhelp = 'none';
	} else {
		getel('adminhelp').style.display='block';
		showhelp = 'visible';
	}
}

function showextras(){
	if(extrasv == 'visible'){
		getel('extras').style.display='none';
		extrasv = 'none';
	} else {
		getel('extras').style.display='block';
		extrasv = 'visible';
	}
}

function reviseimage(size, path, image){
	switch(size){
		case "full":
			getel('previewimage').innerHTML='<img src="'+path+'img/content/images/full_'+image+'" border="0">';		
			break;
		case "halfr":
			getel('previewimage').innerHTML='<img src="'+path+'img/content/images/half_'+image+'" align="right" border="0">';		
			break;
		case "halfl":
			getel('previewimage').innerHTML='<img src="'+path+'img/content/images/half_'+image+'" align="left" border="0">';		
			break;
	}	
}

function checkhighlight(){
	if	(getel('highlight').value='on'){
		getel('warning').style.display = 'inline';
	} else {
		getel('warning').style.display = 'none';
	}
}

function additem(){
	var newvalue = getel('listitems').innetHTML;
	currentCount++;
	counted = 2;
	boxcheck = 1;
	boxvalue = new Array();
	
	newvalue = '<table cellpadding="0" cellspacing="0" style="margin-top:0px;">';
	
	while(counted <= currentCount){
		
		boxid = boxcheck;
		boxid = 'item'+boxid;
		boxvalue[boxid] = getel(boxid).value;
		
		//getel(boxid).value = boxvalue
		alert(boxvalue[boxid]);

		
		newvalue = newvalue+'<tr><td width="135px">Sidebar item '+counted+': </td><td><textarea id="item'+counted+'" name="item'+counted+'" class="sidebar_element">'+boxvalue+'</textarea></td></tr>';
		counted++;
		fields[counted] = true;
	}
	
	newvalue = newvalue + '</table>';
	getel('listitems').innerHTML = newvalue;
}

function addimg(element, code){
	if(element == undefined){
		//alert("help");
	} else {
		currentValue = getel(element).value;
		getel(element).value = currentValue+""+code;
	}
}

function insertin(element, code){
	if(element == undefined){
		//alert("help");
	} else {
		currentValue = getel(element).value;
		getel(element).value = currentValue+""+code;
	}
}

function setfocus(element){
	infocus = element;
}

function yousure(id){
	getel('deletepage-'+id).style.display='none';
	getel('yousure-'+id).style.display='block';
}





function showlarge(image, path){

 	height = (document.body.clientHeight + 40)+"px";
 	getel('largeback').style.height = height;
 	
 	scrolltop = window.pageYOffset;

	//yScroll = document.body.scrollTop;
	//yScroll = document.body.offsetTop
	//alert(yScroll);
	

	if(scrolltop == undefined){
		scrolltop = "42px";
		window.scrollTo(0,42);
 	} else {
      window.scrollTo(0,scrolltop);
      scrolltop = (scrolltop + 42)+"px";
      
 	}
 	// 
 	// scrolltop = (scrolltop+"px";
 	
 	getel('largeimage').style.marginTop = scrolltop;
 	//alert(getel('largeimage').style.marginTop);

	if(showing == true){
		newvalue = '';
		getel('largeback').style.display = 'none';
		getel('largeimage').innerHTML = newvalue;
		getel('largeimage').style.marginTop = "1px";
		showing = false;
	
	} else {
		newvalue = '<div class=\'clicktoclose\'><a style="color: #FFF; font-size: 11px;" href="javascript:showlarge(\'close\', '+path+')">Click image to close.</a></div><a href="javascript:showlarge(\'close\', \''+path+'\')"><img src="'+path+'img/content/images/'+image+'" border="0" alt="" /></a>';
		getel('largeback').style.display = 'block';
		getel('largeimage').innerHTML = newvalue;
		showing = true;
	}

}


/**
gallery functions
**/
function preview(image, path){

	/**
	* establish width, to center to overlay
	**/
	var img = new Image();
	img.src = path+'img/'+image;
	ajaxpagefetcher.load("theImage", "modules/sub.gallery.php?thisImg="+img.src, true);
}

function showhotspot(count){
	start = 0;
	while(start <= (count -1)){
		getel('hotspot_'+start).style.display = "block";
	start++;
	}
}

function hidehotspot(count){
	start = 0;
	while(start <= (count -1)){
		getel('hotspot_'+start).style.display = "none";
	start++;
	}
}

function showcomment(box){
	getel('thecomment_'+box).style.display = "block";
	getel('hotover_'+box).style.display = "block";
}

function hidecomment(box){
	getel('thecomment_'+box).style.display = "none";
	getel('hotover_'+box).style.display = "none";
}

