// JavaScript Document
function showArrow(page) {
	if(page == 'index.php') {
		viewDiv('indeximg');
	} else {
		hideDiv('indeximg');
	}
	if(page == 'bio.php') {
		viewDiv('bioimg');
	} else {
		hideDiv('bioimg');
	}
	if(page == 'photos.php') {
		viewDiv('photosimg');
	} else {
		hideDiv('photosimg');
	}
	if(page == 'services.php') {
		viewDiv('servicesimg');
	} else {
		hideDiv('servicesimg');
	}
	if(page == 'color_management.php') {
		viewDiv('colorimg');
	} else {
		hideDiv('colorimg');
	}
	if(page == 'cancer.php') {
		viewDiv('cancerimg');
	} else {
		hideDiv('cancerimg');
	}
	if(page == 'links.php') {
		viewDiv('linksimg');
	} else {
		hideDiv('linksimg');
	}
	if(page == 'contact.php') {
		viewDiv('contactimg');
	} else {
		hideDiv('contactimg');
	}
}
function doNav(theUrl) {
	document.location.href = theUrl;
}
function viewDiv(div) {
	document.getElementById(div).style.display="block";
}
function hideDiv(div) {
	document.getElementById(div).style.display="none";
}
function pleaseWait(table,row,cell) {
	var x=document.getElementById(table).rows[row].cells
	x[cell].innerHTML="Please Wait..."
}
function deleteCategory(id) {
	var remove = confirm('This will delete this gallery as well as all photos and categories within this gallery.  This action is unrecoverable. Are you sure you want to delete this gallery?');
	if(remove == true) {
		doNav('photos.php?action=process&section=deletecat&id='+id);	
	}
}
function deleteGallery(id) {
	var remove = confirm('This will delete this gallery as well as all photos and categories within this gallery.  This action is unrecoverable. Are you sure you want to delete this gallery?');
	if(remove == true) {
		doNav('admin_photos.php?action=process&section=deletecat&catid='+id);	
	}
}
function deletePhoto(catid,id) {
	var remove = confirm('You are about to delete this photo from the database.  This action is unrecoverable. Are you sure you want to delete this photo?');
	if(remove == true) {
		doNav('admin_photos.php?action=process&section=deletephoto&catid='+catid+'&id='+id);	
	}
}
function showCategory(id,action) {
	var a = document.getElementById('a'+id);
	if(action == 'show') {
		viewDiv('div'+id);
		a.href = 'javascript:showCategory(\''+id+'\',\'hide\');';
	} else if(action == 'hide') {
		hideDiv('div'+id);
		a.href = 'javascript:showCategory(\''+id+'\',\'show\');';
	} else {
		alert(a.href);	
	}
}
function addPhoto(table, sub_count) {
	var tbl = document.getElementById(table);
	var lastRow = tbl.rows.length;
	var iteration = lastRow - sub_count;
	var a = tbl.insertRow(iteration)
	a.innerHTML='<td align="left" colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="0" id="photo'+iteration+'"><tr><td colspan="2"><br></td></tr><tr><td width="100" align="right" valign="top">Add an Image:&nbsp;&nbsp;</td><td align="left" valign="top"><input type="file" class="inputfield" name="image[]" id="image'+iteration+'" size="25">&nbsp;&nbsp;&nbsp;<a href="javascript:removeRow(\'photo'+iteration+'\',\'9\');removeRow(\'photo'+iteration+'\',\'8\');removeRow(\'photo'+iteration+'\',\'7\');removeRow(\'photo'+iteration+'\',\'6\');removeRow(\'photo'+iteration+'\',\'5\');removeRow(\'photo'+iteration+'\',\'4\');removeRow(\'photo'+iteration+'\',\'3\'); removeRow(\'photo'+iteration+'\',\'2\'); removeRow(\'photo'+iteration+'\',\'1\'); removeRow(\'photo'+iteration+'\',\'0\');" class="adminlink"><img src="images/icons/delete.png" align="absbottom" border="0"></a></td></tr><tr><td colspan="2"><img src="images/spacer.gif" width="100%" height="5"></td></tr><tr><td width="100" align="right" valign="top">Caption:&nbsp;&nbsp;</td><td align="left" valign="top"><input type="text" name="desc[]" id="desc'+iteration+'" size="40" class="inputfield"></td></tr><tr><td colspan="2"><img src="images/spacer.gif" width="100%" height="5"></td></tr><tr><td width="100" align="right" valign="top">Homepage?:&nbsp;&nbsp;</td><td align="left" valign="top"><select name="homepage[]" id="homepage'+iteration+'" class="inputfield"><option value="yes">Yes</option><option value="no" selected="selected">No</option></select></td></tr><tr><td colspan="2"><img src="images/spacer.gif" width="100%" height="5"></td></tr><tr><td width="100" align="right" valign="top">Photos Home?:&nbsp;&nbsp;</td><td align="left" valign="top"><select name="photohome[]" id="photohome'+iteration+'" class="inputfield"><option value="yes">Yes</option><option value="no" selected="selected">No</option></select></td></tr><tr><td colspan="2"><img src="images/spacer.gif" width="100%" height="5"></td></tr><tr><td width="100" align="right" valign="top">Order:&nbsp;&nbsp;</td><td align="left" valign="top"><input type="text" name="order[]" id="order'+iteration+'" size="10" class="inputfield"></td></tr></table><input type="hidden" name="iteration[]" id="iteration'+iteration+'" value="'+iteration+'"></td>';
}
function removeRow(table,row) {
	var tbl = document.getElementById(table);
	tbl.deleteRow(row);
}
function removeImg(id) {
	var remove = confirm('Are you sure you want to remove this image?');
	if(remove == true) {
		doNav('photos.php?action=process&section=delete&id='+id);	
	}
}
/*
var request = null;
try {
  request = new XMLHttpRequest();
} catch (trymicrosoft) {
  try {
    request = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (othermicrosoft) {
    try {
      request = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (failed) {
      request = null;
    }
  }
}

if (request == null)
  alert('Your browser does not support AJAX. Some functionality may be disabled. Please upgrade to the latest version of your browser.');

var ajaxRequest = request;
function getThumbs(catid) {
	var thumbDiv = document.getElementById('thumbs');
	if(ajaxRequest) {
		ajaxRequest.open('GET','modules/photothumbs.php?catid='+catid, true);
		ajaxRequest.onreadystatechange = function() {
				if(ajaxRequest.readyState == 4) {
					thumbDiv.innerHTML = ajaxRequest.responseText;
					viewDiv('thumbs');
				}
			}
		ajaxRequest.send(null);
	}
}
var ajaxRequest = request;
function showPhoto(id) {
	var photoDiv = parent.document.getElementById('photolarge');
	photoDiv.innerHTML = '<br><br><br><br><img src="images/progress.gif">';
	if(ajaxRequest) {
		ajaxRequest.open('GET','photolarge.php?photoid='+id, true);
		ajaxRequest.onreadystatechange = function() {
				if(ajaxRequest.readyState == 4) {
					photoDiv.innerHTML = ajaxRequest.responseText;
					new Effect.Appear(id);
				}
			}
		ajaxRequest.send(null);
	}
}*/
// *** S T A R T S C R I P T ***
var waktu=0;

function kiri(){
isi.scrollBy(-10,0);waktu=setTimeout('kiri()',60);
}
function kanan(){
isi.scrollBy(10,0);waktu=setTimeout('kanan()',60);
}
function selesai() {
clearTimeout(waktu);
}
function deleteLink(id) {
	if(confirm('Are you sure you want to delete this link?')) {
		doNav('links.php?action=process&section=delete&id='+id);
	}
}
function accountHover(tableRow, highLight) {
	if (highLight) {
		tableRow.className = "accounthover";
		tableRow.style.cursor="pointer";
	} else {
		tableRow.className = "account";
	}
}
function getThumbs(catid) {
	if(document.getElementById('content').style.display != 'none') {
		new Effect.Fade('thumbs');
	}
	new Ajax.Request('modules/thumbs.php?catid='+catid,
		 {
			method:'get',
			onLoading: function(t) {
			  	if(document.getElementById('content').style.display == 'none') {
					new Effect.BlindDown('content',{duration:1.5});
				}
				document.getElementById('content').innerHTML = '<div id="contentLoading" style="display:none;">Loading...<br /><br /><img src="images/ajax-loader-1.gif" width="24" height="24" /></div>';
			  	new Effect.Appear('contentLoading',{duration:.8});
			},
			onComplete: function(transport){
				new Effect.Fade('contentLoading',{duration:.3});
			  var response = transport.responseText || "no response text";
			  document.getElementById('content').innerHTML = response;
			  	new Effect.Appear('thumbs', { queue: 'end' });
			},
			onFailure: function(){ alert('Something went wrong...') }
		  });
}
var fadeImage = function() {
	new Effect.Appear('fadephoto');
	new Effect.Fade('loadingDiv');
	}
function showPhoto(id) {
	if(document.getElementById('fadephoto').style.display != 'none') {
	new Effect.Fade('fadephoto');
	}
	new Ajax.Request('modules/photolarge.php?photoid='+id,
		 {
			method:'get',
			onLoading: function() {
				new Effect.Appear('loadingDiv');
			},
			onSuccess: function(text){
			  var response = text.responseText || "no response text";
			  document.getElementById('bigphoto').innerHTML = response;
			  document.getElementById('img'+id).onload = fadeImage;
			},
			onFailure: function(){ alert('Something went wrong...') }
		  });
}
function removeTextBox(id) {
	var remove = confirm('This will erase this link and any text associated with it.  This action is unrecoverable. Are you sure you want to delete this link?');
	if(remove == true) {
		doNav('admin_services.php?action=process&section=delete&id='+id);	
	}
}
function removeTextBoxColor(id) {
	var remove = confirm('This will erase this link and any text associated with it.  This action is unrecoverable. Are you sure you want to delete this link?');
	if(remove == true) {
		doNav('admin_color.php?action=process&section=delete&id='+id);	
	}
}
function removeTextBoxCancer(id) {
	var remove = confirm('This will erase this link and any text associated with it.  This action is unrecoverable. Are you sure you want to delete this link?');
	if(remove == true) {
		doNav('admin_cancer.php?action=process&section=delete&id='+id);	
	}
}
function deleteProduct(id) {
	var remove = confirm('This will delete this product from the database.  This action is unrecoverable. Are you sure you want to delete this product?');
	if(remove == true) {
		doNav('admin_shopping.php?action=process&section=delete&id='+id);	
	}
}
function deleteShipping(id) {
	var remove = confirm('This will delete this shipping option from the database.  This action is unrecoverable. Are you sure you want to delete this shipping option?');
	if(remove == true) {
		doNav('admin_shopping.php?action=process&section=deleteship&id='+id);	
	}
}
var larrow = new Image();
larrow.src = 'images/left.gif';
var rarrow = new Image();
rarrow.src = 'images/right.gif';
var fileupload = new Image();
fileupload.src = 'images/file_upload.gif';

function startProgressBar() {
	document.getElementById('progressHolder').innerHTML = '<br /><img src="images/file_upload.gif"><br>Please Wait While Your File Is Uploaded<br>This may take several minutes.<br /><br />';
}