
var image_counter = 0;
var uploaded = false;

function show_image_controls(radio_ob){
 u_div = xGetElementById("upload_div");
 if(radio_ob.value == "upload"){
    u_div.style.display = "block";
    }
    else u_div.style.display = "none";
    
}

function hide_photo_tools(){
 u_div = xGetElementById("upload_div");
 u_div.style.display = "none";   
 
 p_div = xGetElementById("prog_bar_container");
 p_div.style.display = "none";
}

function change_process_option(){
   //alert("uploaded = " + uploaded);
   if(!uploaded){
      var t_photo_image = xGetElementById("main_pimg");
      var process_select = xGetElementById("processing_option");
      var processing_option = process_select.options[process_select.selectedIndex].value;
      
      var border_select = xGetElementById("border_option");
      var border_option = border_select.options[border_select.selectedIndex].value;
     // alert("border option = " + border_option);
     
      img_container = xGetElementById("image_holder");
      if(border_option == "white"){
	 img_container.style.backgroundColor = "#000000";
	 }
	 else img_container.style.backgroundColor = "#FFFFFF";
      
      t_photo_image.src = "/include/render_photo_image.php?image_dir=default&border=" + border_option + "&file=" + escape(default_image) + "&processing_option=" + escape(processing_option) + "&product_id=" + product_id + "&image_counter=" + image_counter;
      image_counter++;
      return;
      }
   refresh_image(true);
}

function refresh_image(doit){
   if(!doit)return;
   /*var t_photo_image = xGetElementById("main_pimg");
   
   t_photo_image.width = 360;
   t_photo_image.height = "";*/
   
   var process_select = xGetElementById("processing_option");
   var processing_option = process_select.options[process_select.selectedIndex].value;
   
   var border_select = xGetElementById("border_option");
   var border_option = border_select.options[border_select.selectedIndex].value;
   
   img_container = xGetElementById("image_holder");
   if(border_option == "white"){
      img_container.style.backgroundColor = "#000000";
      }
      else img_container.style.backgroundColor = "#FFFFFF";
   //alert("changing image to: " + "/include/render_photo_image.php?product_id=" + product_id);
   img_container.innerHTML = "<img style=\"border-width:0px\" src=\"/include/render_photo_image.php?border=" + border_option + "&processing_option=" + escape(processing_option) + "&product_id=" + product_id + "&image_counter=" + image_counter + "\">";
   //set_photo_upload();
   image_counter++;
   }