var winW=0;
var winH=0;
var lpos=0;
var tpos=0;
var picdesc="0";
var ctime="";
var timob="";

function checkcursor(oBj){
	if(oBj.src!="http://www.lizcollini.com/images/query2.jpg"){
		oBj.style.cursor='pointer';
		oBj.title='click to see larger image ...';
		oBj.alt='click to see larger image ...';
		}
}

function testform(oBj){
	document.trans.uname.value=document.dumb.uname1.value;
	document.trans.pword.value=document.dumb.pword1.value;
	if(document.trans.uname.value=="" || document.trans.uname.value=="username" || document.trans.pword.value=="" || document.trans.uname.value=="password"){
		alert("Please enter a UserName & Password combination ...")
	}
	else{
		document.trans.submit();
	}
}

function clearbox(oBj){
	oBj.value="";
}

function showme(){
	trans.action="../pages/galleryview.php";
	trans.submit();
}

function relocate(add){
	location=add;
}

function greyup(a){
	a.style.color='#63A2CA';
}

function greydown(a){
	a.style.color='#4C4C4C';
}

document.onkeypress=testinput;

function testinput(e){
	if(location.pathname=='/mindex.html'|| location.pathname=='/'){
		var evtobj=window.event? event : e //distinguish between IE's explicit event object (window.event) and Firefox's implicit.
		var unicode=evtobj.charCode? evtobj.charCode : evtobj.keyCode
		var actualkey=String.fromCharCode(unicode)
	
		if(unicode==13){
			testform(document.trans);
		}
	}
}

function tableviewswap(){
	
	document.getElementById('folderview').style.display='none';
	document.getElementById('indexview').style.display='block';
}

function divswap(mysrc,myimg){
	if(mysrc!="http://www.lizcollini.com/images/query2.jpg"){
		rExp=/_m\./gi;
		
		mynewsrc=mysrc.replace(rExp,"_l\.");
		
		document.getElementById('bigimage').src=mynewsrc;
		//if(document.getElementById('picturename').innerHTML=="&nbsp;")document.getElementById('picturename').innerHTML=myimg;
		
		document.getElementById('folderview').style.display='none';
		
		document.getElementById('bigimageview').style.display='block';
	}
}


function divswapback(){
	document.getElementById('folderview').style.display='block';
	document.getElementById('bigimageview').style.display='none';
	document.getElementById('bigimage').src="";
}

function replacepic(fldr,pic,desc,ind,sum,id,nam,dim,med){
	rExp=/_m\./gi;

	if(ind<sum){
		var plusind=(ind+1);
		document.getElementById('rarr').innerHTML="<img id=rarrim onClick=\"replacepic('"+fldr+"','../imagestore/"+fldr+"/"+imArray[plusind][0]+"_m.jpg','"+imArray[plusind][1]+"',"+plusind+","+sum+","+imArray[plusind][2]+",'"+imArray[plusind][3]+"','"+imArray[plusind][4]+"','"+imArray[plusind][5]+"')\" src=\"../images/rarr.jpg\" width=24px title=\"next image\">";
		document.getElementById('rarrim').style.display='block';
		
		document.getElementById('bigrarr').innerHTML="<img id=bigrarrim onClick=\"replacepic('"+fldr+"','../imagestore/"+fldr+"/"+imArray[plusind][0]+"_m.jpg','"+imArray[plusind][1]+"',"+plusind+","+sum+","+imArray[plusind][2]+",'"+imArray[plusind][3]+"','"+imArray[plusind][4]+"','"+imArray[plusind][5]+"')\" src=\"../images/next.gif\" width=24px title=\"next image\">";
		
		document.getElementById('bigrarrim').style.display='block';
	}
	else{
		document.getElementById('rarr').innerHTML="";
		document.getElementById('bigrarr').innerHTML="";
	}
	
	if(ind>1){
		var minusind=(ind-1);
		document.getElementById('larr').innerHTML="<img id=larrim onClick=\"replacepic('"+fldr+"','../imagestore/"+fldr+"/"+imArray[minusind][0]+"_m.jpg','"+imArray[minusind][1]+"',"+minusind+","+sum+","+imArray[minusind][2]+",'"+imArray[minusind][3]+"','"+imArray[minusind][4]+"','"+imArray[minusind][5]+"')\" src=\"../images/larr.jpg\" width=24px title=\"previous image\">";
		document.getElementById('larrim').style.display='block';
		
		document.getElementById('biglarr').innerHTML="<img id=biglarrim onClick=\"replacepic('"+fldr+"','../imagestore/"+fldr+"/"+imArray[minusind][0]+"_m.jpg','"+imArray[minusind][1]+"',"+minusind+","+sum+","+imArray[minusind][2]+",'"+imArray[minusind][3]+"','"+imArray[minusind][4]+"','"+imArray[minusind][5]+"')\" src=\"../images/prev.gif\" width=24px title=\"previous image\">";
		
		document.getElementById('biglarrim').style.display='block';
	}
	else{
		document.getElementById('larr').innerHTML="";
		document.getElementById('biglarr').innerHTML="";
		
	}

	document.getElementById('imageviewerpic').src=pic;
	document.getElementById('picname').innerHTML=nam+'<br>'+dim+'<br>'+med;
	//document.getElementById('details').innerHTML=dim+'&nbsp;&nbsp;&nbsp;'+med+'<br>';
	
	document.getElementById('imgdesc1').innerHTML=desc;
	document.getElementById('imgdesc2').innerHTML=desc;
	
	document.getElementById('imgid').innerHTML=id;
	
	mynewsrc=pic.replace(rExp,"_l\.");
	document.getElementById('bigimage').src=mynewsrc;
	
	document.getElementById('bgname').innerHTML=nam;
	
	document.getElementById('bgdims').innerHTML=dim;
	document.getElementById('bgmedium').innerHTML=med;
	
}

function borderup(oBj){
	oBj.style.borderColor="#63A2CA";
}

function borderdown(oBj){
	oBj.style.borderColor="#ffffff";
}

function borderup1(oBj){
	oBj.style.borderColor="#63A2CA";
	oBj.style.filter='alpha(opacity=70)';
}

function borderdown1(oBj){
	oBj.style.borderColor="#ffffff";
	oBj.style.filter='alpha(opacity=100)';
}

function showimage(){
	winsize();
	findcenter('width=300 height=200');
	document.getElementById('imagediv').style.posLeft=lpos;
	document.getElementById('imagediv').style.posTop=tpos;
	document.getElementById('imagediv').style.display='block';
}

function showcontact(){
	winsize();
	findcenter('width=350 height=480');
	document.getElementById('contactarea').style.posLeft=lpos;
	document.getElementById('contactarea').style.posTop=tpos;
	document.getElementById('contactarea').style.display='block';
}

function showexhibs(){
	winsize();
	findcenter('width=830 height=350');
	document.getElementById('exhibitions').style.posLeft=lpos;
	document.getElementById('exhibitions').style.posTop=tpos;
	document.getElementById('exhibitions').style.display='block';
}

function showcv(){
	location="cview.php";
}

function showhome(){
	location="galleryview.php";
}

function makefolder(){
	winsize();
	findcenter('width=300 height=100');
	document.getElementById('makefold').style.posLeft=lpos;
	document.getElementById('makefold').style.posTop=tpos;
	document.getElementById('makefold').style.display='block';
}

function delfolder(){
	winsize();
	findcenter('width=300 height=100');
	document.getElementById('delfold').style.posLeft=lpos;
	document.getElementById('delfold').style.posTop=tpos;
	var checkboxstring="";
	var len=dirArray.length;
	
	for(i=0;i<len;i++){
		checkboxstring+="<div class=deldir onMouseOver='radioup(this)' onMouseOut='radiodown(this)' onClick='radiocheck("+i+")'>"+dirArray[i]+"</div>&nbsp;<input class=radiobox id="+i+" type=radio name=emptydir value='"+dirArray[i]+"'><br>";
	}
	
	document.getElementById('emptyfolders').innerHTML=checkboxstring;
	document.getElementById('delfold').style.display='block';
}

function radioup(oBj){
	oBj.style.backgroundColor='#7BB4D6';
}

function radiodown(oBj){
	oBj.style.backgroundColor='#D1D6D9';
}
function radiocheck(rad){
	document.getElementById(rad).checked=true;
}

function deleteimage(){
	winsize();
	findcenter('width=300 height=200');
	document.getElementById('delimagediv').style.posLeft=lpos;
	document.getElementById('delimagediv').style.posTop=tpos;
	document.delimage.delimagefile.value=document.getElementById('imageviewerpic').src;
	document.getElementById('delpichoose').src=document.getElementById('imageviewerpic').src;
	document.delimage.id.value=document.getElementById('imgid').innerHTML;
	document.getElementById('delimagediv').style.display='block';
}

function divgo(){
	document.getElementById('imagediv').style.display='none';
	document.sendimage.descr.value="";
	document.sendimage.imagefile.value="";
	document.getElementById('pichoose').src="../images/newimage.jpg";
}

function contactgo(){
	document.getElementById('contactarea').style.display='none';
}

function exhibsgo(){
	document.getElementById('exhibitions').style.display='none';
}

function foldivgo(){
	document.getElementById('makefold').style.display='none';
	document.createfolder.foldername.value="";
}

function delfoldivgo(){
	document.getElementById('delfold').style.display='none';
}

function editdivgo(){
	document.getElementById('editimg').style.display='none';
}

function deldivgo(){
	document.getElementById('delimagediv').style.display='none';
	document.delimage.delimagefile.value="";
	document.getElementById('pichoose').src="";
}

function winsize(){
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = window.innerWidth;
			winH = window.innerHeight;
 			}
 		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
			}
	}
}

function findcenter(sizestring){
	var myReg= new RegExp("width=(.*) height=(.*)");
	var results= sizestring.match(myReg);
	
	
	lpos=Math.round(parseFloat((winW-results[1])/2));
	tpos=Math.round(parseFloat((winH-results[2])/2));
}

function formsub(oBj){
	if(oBj.imagefile.value==''){
		alert('please select image file');
	}
	else{
		oColl=sendimage.elements;
		num2=oColl.length;
		for(count=0;count<num2;count++){
		cleantext(sendimage.elements(count))
		}
		oBj.submit();
	}
}

function delformsub(oBj){
	if(confirm('Final chance to back out ... are you sure?')){
		oBj.submit();
	}
}

function revealpic(){
	//if(picdesc=="1"){
		if(sendimage.imagefile.value!=""){
			//document.getElementById('pichoose').src=sendimage.imagefile.value;
			document.getElementById('pichoose').src='c:\inetpub/wwwroot/site_files/www.paulcainsmith/html/images/pcslogo.jpg';
			picdesc="0";
			document.getElementById('imagefile').blur();
			alert('hello')
		}
		
	//}
	//else{
	//	picdesc="1";
	//}
}

function viewimg(pic){
	var newcontent=pic;
	var finalcontent=imgtemplate.replace(/content/gi,newcontent);
	
	winsize();
	findcenter('width=300 height=200');
	document.getElementById('medimagediv').style.posLeft=lpos;
	document.getElementById('medimagediv').style.posTop=tpos;
	document.getElementById('medimagediv').innerHTML=finalcontent;
	document.getElementById('medimagediv').style.display='block';
}

function closediv(oBj){
	document.getElementById(oBj).style.display='none';
}

function cleantext(oBj){
	var oldstring=oBj.value;
	rExp1=/'/gi;
	rExp2=/"/gi;
	rExp3=/\\/gi;
	newstring=oldstring.replace(rExp1,"`");
	newstring1=newstring.replace(rExp2,"`");
	newstring2=newstring1.replace(rExp3,"");
	oBj.value=newstring2;
}

var oldlay;
	
function layh(lay)
{
	if(oldlay)
	{
		document.getElementById(oldlay).style.display='none';
	}
	
	document.getElementById(lay).style.display='block';
	document.message.elem.value=lay;
	oldlay=lay;
}

function layest(urlparam)
{
	if(urlparam)
	{
		document.getElementById(urlparam).style.display='block';
		oldlay=urlparam;
	}
}

function unencrypt(){
	var myText="";
	mess=bert.value;
	len=mess.length;
	inc=len/3;
	for(x=0;x<len;x+=3){
		myText=myText+"&#"+eval(mess.substring(x,x+3)-inc)+";";
		}	
	return("<a href='mailto:"+myText+"' id=ema>"+myText+"</a>")
}

function indeximgover(oBj){
	oBj.style.filter='alpha(opacity=60)';
	oBj.style.border='1px #6977B6 solid';
}

function indeximgout(oBj){
	oBj.style.filter='alpha(opacity=100)';
	oBj.style.border='1px #C0BEBE solid';
}
