function showprocessing(){
  document.getElementById("processing").style.display = "inline";
}

//var diagOn = 0;
//var newWin = 0;

function makeWin(url,name,feat,diagOn,cnfrm) {
        if (cnfrm) {
                if (confirm("Creating a 3D Text image will overwrite your current image. Do you wish to continue?")) {
                        newWin = window.open(url,name,feat);
                }
        } else {
                newWin = window.open(url,name,feat);
        }
}

function confirmClose(loc) {
        if (confirm("Are you sure you wish to exit this session of GIFMagic?")) {
                location.href = loc;
        }
}


function processing(loc) {
//        changecss('#processing','display','inline');
        document.getElementById("processing").style.display = "inline";
        location.href = loc;
}

function confirmRevert(loc) {
        if (confirm("Are you sure you wish to start over? (All changes will be lost)")) {
                location.href = loc;
        }
}



var preview3dtext = 0;
function closeWin() {
        if (newWin && !newWin.closed && !preview3dtext) {
                newWin.close();
        }
}

function AutoGo(url,text,menu) {
        menu.selectedIndex = 0;
        closeWin();
        if (url && url != 'ThisItemIsTurnedOff') {
                location.href = url;
        } else if (url) {
                alert("Cannot " + text);
        }
}

function openValidate(theform) {
        if (!theform.theimage.value) {
                var get = "Please enter the URL of an image before pressing submit.";
                var upload = "Please press the 'Browse' button and locate an image on your hard drive before clicking submit.";
                var theerror = (theform.name == 'imgGet') ? get : upload;
//              alert(theerror);
                return true;
        } else {
                return true;
        }
}

//window.name = "GIFMAGIC";

function changeSize(com,cw,ch) {
//alert("com " + com + " " + cw);
  var zoom=1;
  if(com == 'zoomin'){
    //first read the cookie (if any) to get the initial value - if none, then set to 1
    zoom=readCookie('zoom');
    if(zoom){ 
//alert("zoom " + zoom );
      zoom=parseFloat(zoom);
      if((zoom + .25) * ch < 500 && (zoom +.25) * cw < 800){
         zoom=zoom+.25;//this converts the string to a number
      }
//      document.getElementById("mainimage").height=zoom * ch;
      document.getElementById("mainimage").style.height=zoom * ch + "px";
//      document.form["image"]["height"].value=zoom * ch;
      document.getElementById("mainimage").style.width=zoom * cw +"px";
//      document.getElementById("mainimage").width=zoom * cw;
//alert("zoom " + zoom );
      createCookie('zoom',zoom,7);
    }else{
      document.getElementById("mainimage").height= ch;
      document.getElementById("mainimage").width= cw;
      createCookie('zoom',1,7);
    }
  }
  if(com == 'zoomout'){
    zoom=readCookie('zoom');
    if(zoom){
      zoom=parseFloat(zoom);
      if(zoom>=.5){
        zoom=zoom-.25;
      }
//      document.getElementById("mainimage").height=zoom * ch;
//      document.getElementById("mainimage").width=zoom * cw;
      document.getElementById("mainimage").style.height=zoom * ch +"px";
      document.getElementById("mainimage").style.width=zoom * cw +"px";
      createCookie('zoom',zoom,7);
    }else{
      document.getElementById("mainimage").height= ch;
      document.getElementById("mainimage").width= cw;
      createCookie('zoom',1,7);
    }
  }
  zoom=100*zoom;
  zoom="Zoom Level:"+zoom+"%";
  document.getElementById("level").value=zoom;
}



// cookie stuff found at http://www.quirksmode.org/js/cookies.html - wow, great article guys!
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function resizeIt(letter1) {
	if (document.resizeform.constrain.checked) {
		var letter2 = (letter1 == 'w') ? 'h' : 'w';
		var changed = eval("document.resizeform." + letter1);
		var xchanged = eval("document.resizeform.x" + letter1);
		var other = eval("document.resizeform." + letter2);
		var xother = eval("document.resizeform.x" + letter2);
		other.value = Math.round(xother.value * (changed.value / xchanged.value));
		xchanged.value = changed.value;
		xother.value = other.value;
	}
}





