/* $Id: SCRIPTskink.js 358 2007-10-01 21:47:54Z timw $ */

/**
* SKINK Skin special Javascript Functions
*
* @package skink
* @author $Author: timw $
* @version $Rev: 358 $ $Date: 2007-10-02 10:47:54 +1300 (Tue, 02 Oct 2007) $
* @url $HeadURL: http://elibcsystems.dyndns.org/svn/skink/tags/1.5.0/_skins/default/SCRIPTskink.js $
*/
function SKINK_JS_ajaxconnect() {
  try {
    AJAXrequest = new XMLHttpRequest(); /* e.g. Firefox */
  } 
  catch(e) {
    try {
      AJAXrequest = new ActiveXObject("Msxml2.XMLHTTP");  /* some versions IE */
    } 
    catch (e) {
      try {
        AJAXrequest = new ActiveXObject("Microsoft.XMLHTTP");  /* some versions IE */
      } 
      catch (E) {
        AJAXrequest = false;
      }
    }
  }
  return AJAXrequest;  
}

function SKINK_JS_resetmessages() {
  TWD_JS_showHideObjects('ajaxsaved','none');
  TWD_JS_showHideObjects('ajaxerror','none');        
  TWD_JS_showHideObjects('ajaxsaving','none');
 	/* return true */
	return true;
}

function SKINK_JS_parseformvars(theForm,valFunc){
  var str = "";
  var valueArr = null;
  var val = "";
  var cmd = "";
  for(var i = 0;i < theForm.elements.length;i++) {
    switch(theForm.elements[i].type) {
      case "text":
        str += theForm.elements[i].name + "=" + escape(theForm.elements[i].value) + "&";
      break;
      case "checkbox":
        if (theForm.elements[i].checked == true) str += theForm.elements[i].name + "=" + theForm.elements[i].value + "&";
      break;
      case "hidden":
        str += theForm.elements[i].name + "=" + escape(theForm.elements[i].value) + "&";
      break;
      case "select-one":
        str += theForm.elements[i].name + "=" + theForm.elements[i].options[theForm.elements[i].selectedIndex].value + "&";
      break;
    }
  }
  str = str.substr(0,(str.length - 1));
  return str;
}

function SKINK_JS_popup(theURL,theHeading,afterFunction) {
  /* Init the vars */
  var thePopupHeader = TWD_JS_findObj('skinkajaxpopupheader');
  var thePopupContent = TWD_JS_findObj('skinkajaxpopupcontent');
  /* Show/Hide the background and loading image */
  TWD_JS_showHideObjects('skinkajaxbg','block');
  TWD_JS_showHideObjects('skinkajaxbg_loading','');
  /* Set up Ajax */
  AJAXrequest = SKINK_JS_ajaxconnect();
  /* Tell the user if Ajax is not going to work */
  if (!AJAXrequest) {
    alert('This method of using skink is not supported by your browser - Please contact the administrator for more information');
    return false;
  }
  /* Get the details to the server */
  AJAXrequest.onreadystatechange = function () {
    if (AJAXrequest.readyState == 4) {
      thePopupHeader.innerHTML = theHeading;
      thePopupContent.innerHTML = AJAXrequest.responseText;
      /* Show/Hide the popup and loading image */
      TWD_JS_showHideObjects('skinkajaxbg_loading','none');
      TWD_JS_showHideObjects('skinkajaxpopup','block');
      /* after function */
      if (afterFunction) {
          eval(afterFunction);
      }
    }
  }
  AJAXrequest.open('GET',theURL,true);
  AJAXrequest.send(null); 
  
 	/* return true */
	return true;
}

function SKINK_JS_popupclose() {
  /* Init the vars */
  var thePopupHeader = TWD_JS_findObj('skinkajaxpopupheader');
  var thePopupContent = TWD_JS_findObj('skinkajaxpopupcontent');
  /* Show/Hide the objects */
  TWD_JS_showHideObjects('skinkajaxbg','none');
  TWD_JS_showHideObjects('skinkajaxpopup','none');

  thePopupHeader.innerHTML = '';
  thePopupContent.innerHTML = '';
}



























































function SKINK_JS_calculatenutrionalinfo(theInfoName) {
  /* the elements */
  var theServingSize = TWD_JS_findObj('servings_size');
  var theServing = TWD_JS_findObj(theInfoName + '_serving');
  var the100 = TWD_JS_findObj(theInfoName + '_100');
  /* the calculatation */
  if (isNaN(the100.value) && isNaN(theServingSize.value)) {
     theServing.value = '0';
  } else {
    theMultiplier = the100.value / theServingSize.value;
    alert(theMultiplier);
    theServing.value = theMultiplier * the100.value;
    
  }
}






function SKINK_JS_newcategory(theURL) {
  /* Init things */
  var categoryname = '';
  var theCategoryName = '';
  var theNewoptionImg = TWD_JS_findObj('newoption');
  var theLoadingImg = TWD_JS_findObj('newoption_loading');  
  var theNewoptionMsg = TWD_JS_findObj('newoption_message');  
  var allowedValues = "abcdefghijklmnopqrstuvwxyz1234567890_";
  var theCategories = TWD_JS_findObj('category_id');
  var theOption = document.createElement('option');
  /* Set the images to loading */
  theNewoptionImg.style.display = 'none';
  theLoadingImg.style.display = '';
  theNewoptionMsg.style.display = 'none';
  /* Set up Ajax */
  AJAXrequest = SKINK_JS_ajaxconnect();
  /* Tell the user if Ajax is not going to work */
  if (!AJAXrequest) {
    alert('This method of adding categories is not supported by your browser - Please contact the administrator for more information');
    return false;
  }
  /* Get the category to add */
  var categoryname = prompt('Please enter a new category name:');
  if (categoryname == '' || categoryname == null) {
    theNewoptionImg.style.display = '';
    theLoadingImg.style.display = 'none';
    theNewoptionMsg.style.display = 'none';
    return false;
  }
  /* Iterate through the allowedvalues to check the categoryname */
  for (i=0;i<categoryname.length; i++) {
    var c = categoryname.charAt(i);
    c = c.toLowerCase();
    if (allowedValues.indexOf(c) >= 0) {
       theCategoryName += categoryname.charAt(i);
    }
  }
  
  /* Check the foldername length after charactors have been stripped */
  if (theCategoryName.length == 0) {
    alert('A category name must be only contain alphanumeric charactors.');
    return false;    
  }
  /* Make the post */
  thePost = 'FORMid=' + encodeURI('new_category');
  thePost += '&name_category=' + encodeURI(theCategoryName);
  /* Send the category to the server */
  AJAXrequest.onreadystatechange = function () {
    if (AJAXrequest.readyState == 4) {
      if (AJAXrequest.responseText != '0' && (! isNaN(AJAXrequest.responseText)) && AJAXrequest.responseText.length != 0) {
        theNewoptionImg.style.display = '';
        theLoadingImg.style.display = 'none';
        theNewoptionMsg.style.display = '';
        theNewoptionMsg.className = 'notices';
        theNewoptionMsg.innerHTML = 'You successfully added the category.';
        /* Add the new option to the menu and select it */
        theOption.setAttribute('value',AJAXrequest.responseText);
        theOption.innerHTML = theCategoryName;
      	theCategories.appendChild(theOption);
      	theCategories.options[theOption.index].selected = true;
      } else {
        theNewoptionImg.style.display = '';
        theLoadingImg.style.display = 'none';        
        theNewoptionMsg.style.display = '';
        theNewoptionMsg.className = 'errors';        
        theNewoptionMsg.innerHTML = AJAXrequest.responseText;
      }
    }
  }
  AJAXrequest.open('POST',theURL,true);
  AJAXrequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');  
  AJAXrequest.send(thePost); 
   
 	/* return true */
	return true;
}












function SKINK_JS_shoppingcart_nutritionalinfosave(theURL,theForm,debugMode) {
  /* Init the vars */
  var theErrorMsg = TWD_JS_findObj('ajaxerror');   
  /* Display the load image */
  TWD_JS_showHideObjects('ajaxsaved','none');
  TWD_JS_showHideObjects('ajaxerror','none');        
  TWD_JS_showHideObjects('ajaxsaving','');
  /* Set up Ajax */
  AJAXrequest = SKINK_JS_ajaxconnect();
  /* Tell the user if Ajax is not going to work */
  if (!AJAXrequest) {
    alert('This method of using skink is not supported by your browser - Please contact the administrator for more information');
    return false;
  }
  /* Get the details to the server */
  AJAXrequest.onreadystatechange = function () {
    if (AJAXrequest.readyState == 4) { 
      if (debugMode) {
        return true;
      } else if (!isNaN(AJAXrequest.responseText) && AJAXrequest.responseText != '0') {
        /* update the display fields */
        var displayServingsPerPackage = TWD_JS_findObj('display_servings_perpackage');
        var formServingsPerPackage = TWD_JS_findObj('servings_perpackage');
        displayServingsPerPackage.innerHTML = formServingsPerPackage.value;
        var displayServingsSize = TWD_JS_findObj('display_servings_size');
        var formServingsSize = TWD_JS_findObj('servings_size');
        displayServingsSize.innerHTML = formServingsSize.value;
        var displayServingsUnit = TWD_JS_findObj('display_servings_unit');
        var formServingsUnit = TWD_JS_findObj('servings_unit');
        displayServingsUnit.innerHTML = formServingsUnit.options[formServingsUnit.selectedIndex].value;

        var displayEnergyServing = TWD_JS_findObj('display_energy_serving');
        var formEnergyServing = TWD_JS_findObj('energy_serving');
        displayEnergyServing.innerHTML = formEnergyServing.value;
        var displayEnergy100 = TWD_JS_findObj('display_energy_100');
        var formEnergy100 = TWD_JS_findObj('energy_100');
        displayEnergy100.innerHTML = formEnergy100.value;
        var displayProteinServing = TWD_JS_findObj('display_protein_serving');
        var formProteinServing = TWD_JS_findObj('protein_serving');
        displayProteinServing.innerHTML = formProteinServing.value;
        var displayProtein100 = TWD_JS_findObj('display_protein_100');
        var formProtein100 = TWD_JS_findObj('protein_100');
        displayProtein100.innerHTML = formProtein100.value;
        var displayFatServing = TWD_JS_findObj('display_fat_serving');
        var formFatServing = TWD_JS_findObj('fat_serving');
        displayFatServing.innerHTML = formFatServing.value;
        var displayFat100 = TWD_JS_findObj('display_fat_100');
        var formFat100 = TWD_JS_findObj('fat_100');
        displayFat100.innerHTML = formFat100.value;
        var displaySaturatedServing = TWD_JS_findObj('display_saturated_serving');
        var formSaturatedServing = TWD_JS_findObj('saturated_serving');
        displaySaturatedServing.innerHTML = formSaturatedServing.value;
        var displaySaturated100 = TWD_JS_findObj('display_saturated_100');
        var formSaturated100 = TWD_JS_findObj('saturated_100');
        displaySaturated100.innerHTML = formSaturated100.value;
        var displayCarbsServing = TWD_JS_findObj('display_carbs_serving');
        var formCarbsServing = TWD_JS_findObj('carbs_serving');
        displayCarbsServing.innerHTML = formCarbsServing.value;
        var displayCarbs100 = TWD_JS_findObj('display_carbs_100');
        var formCarbs100 = TWD_JS_findObj('carbs_100');
        displayCarbs100.innerHTML = formCarbs100.value;
        var displaySugarsServing = TWD_JS_findObj('display_sugars_serving');
        var formSugarsServing = TWD_JS_findObj('sugars_serving');
        displaySugarsServing.innerHTML = formSugarsServing.value;
        var displaySugars100 = TWD_JS_findObj('display_sugars_100');
        var formSugars100 = TWD_JS_findObj('sugars_100');
        displaySugars100.innerHTML = formSugars100.value;
        var displaySodiumServing = TWD_JS_findObj('display_sodium_serving');
        var formSodiumServing = TWD_JS_findObj('sodium_serving');
        displaySodiumServing.innerHTML = formSodiumServing.value;
        var displaySodium100 = TWD_JS_findObj('display_sodium_100');
        var formSodium100 = TWD_JS_findObj('sodium_100');
        displaySodium100.innerHTML = formSodium100.value;
        /* restore the saved message */
        TWD_JS_showHideObjects('ajaxsaving','none');
        TWD_JS_showHideObjects('ajaxsaved','');
        /* Close the window and display the details */
        SKINK_JS_popupclose();
      } else if (AJAXrequest.responseText != '0')  {
        theErrorMsg.innerHTML = '<img src="_skins/default/images/ICONajaxerror_red.gif" />' + AJAXrequest.responseText;      
        TWD_JS_showHideObjects('ajaxsaving','none');
        TWD_JS_showHideObjects('ajaxerror','');        
      } else {
        TWD_JS_showHideObjects('ajaxsaving','none');
        TWD_JS_showHideObjects('ajaxerror','none');        
        TWD_JS_showHideObjects('ajaxerrormsg','block');        
      }
    }
  }
  AJAXrequest.open('POST',theURL,true);
  AJAXrequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');  
  AJAXrequest.send(SKINK_JS_parseformvars(theForm)); 
   
 	/* return true */
	return true;
}







function SKINK_JS_shoppingcart_ingredientssave(theURL,theForm,debugMode) {
  /* Init the vars */
  var theErrorMsg = TWD_JS_findObj('ajaxerror');   
  /* Display the load image */
  TWD_JS_showHideObjects('ajaxsaved','none');
  TWD_JS_showHideObjects('ajaxerror','none');        
  TWD_JS_showHideObjects('ajaxsaving','');
  /* Set up Ajax */
  AJAXrequest = SKINK_JS_ajaxconnect();
  /* Tell the user if Ajax is not going to work */
  if (!AJAXrequest) {
    alert('This method of using skink is not supported by your browser - Please contact the administrator for more information');
    return false;
  }
  /* Get the details to the server */
  AJAXrequest.onreadystatechange = function () {
    if (AJAXrequest.readyState == 4) {
      if (debugMode) {
        return true;
      } else if (AJAXrequest.responseText.substring(0,1) == '1') {
        alert(AJAXrequest.responseText);
        /* update the display fields */
        var displayIngredients = TWD_JS_findObj('display_ingredients');
        displayIngredients.innerHTML = AJAXrequest.responseText.substring(1,AJAXrequest.responseText.length);
        /* restore the saved message */
        TWD_JS_showHideObjects('ajaxsaving','none');
        TWD_JS_showHideObjects('ajaxsaved','');
        /* Close the window and display the details */
        SKINK_JS_popupclose();
      } else if (AJAXrequest.responseText != '0')  {
        theErrorMsg.innerHTML = '<img src="_skins/default/images/ICONajaxerror_red.gif" />' + AJAXrequest.responseText;      
        TWD_JS_showHideObjects('ajaxsaving','none');
        TWD_JS_showHideObjects('ajaxerror','');        
      } else {
        TWD_JS_showHideObjects('ajaxsaving','none');
        TWD_JS_showHideObjects('ajaxerror','none');        
        TWD_JS_showHideObjects('ajaxerrormsg','block');        
      }
    }
  }
  //alert(SKINK_JS_parseformvars(theForm));
  AJAXrequest.open('POST',theURL,true);
  AJAXrequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');  
  AJAXrequest.send(SKINK_JS_parseformvars(theForm)); 
   
 	/* return true */
	return true;
}






function SKINK_JS_shoppingcart_newingredientssave(theURL) {
  /* Init things */
  var theIngredientName = TWD_JS_findObj('ingredient_name');
  var theIngredientWarning = TWD_JS_findObj('ingredient_warning');  
  var theNewLabel = document.createElement('label');
  var theIngredientsList = TWD_JS_findObj('ingredientscheckboxes');
  /* Display the load image */
  TWD_JS_showHideObjects('newingredientajaxsaved','none');
  TWD_JS_showHideObjects('newingredientajaxerror','none');        
  TWD_JS_showHideObjects('newingredientajaxsaving','');
  /* Set up Ajax */
  AJAXrequest = SKINK_JS_ajaxconnect();
  /* Tell the user if Ajax is not going to work */
  if (!AJAXrequest) {
    alert('This method of adding ingredients is not supported by your browser - Please contact the administrator for more information');
    return false;
  }
  /* Get the category to add */
  var ingredientname = theIngredientName.value;
  var ingredientwarning = theIngredientWarning.options[theIngredientWarning.selectedIndex].value
  if (ingredientname == '' || ingredientname == null) {
    TWD_JS_showHideObjects('newingredientajaxerror','');        
    TWD_JS_showHideObjects('newingredientajaxsaving','none');
    var theErrorPane = TWD_JS_findObj('newingredientajaxerror')
    theErrorPane.innerHTML = '<img src="_skins/default/images/ICONajaxerror_red.gif" /><ul><li>An ingredient is required</li></ul>';
    return false;
  }
  
  /* Check the foldername length after charactors have been stripped */
  if (ingredientname.length == 0) {
    alert('A ingredient name must be only contain alphanumeric charactors.');
    TWD_JS_showHideObjects('newingredientajaxerror','');        
    TWD_JS_showHideObjects('newingredientajaxsaving','none');
    var theErrorPane = TWD_JS_findObj('newingredientajaxerror')
    theErrorPane.innerHTML = '<img src="_skins/default/images/ICONajaxerror_red.gif" /><ul><li>An ingredient name must be only contain alphanumeric charactors.</li></ul>';
    return false;
  }
  /* Make the post */
  thePost = 'FORMid=' + encodeURI('new_ingredient');
  thePost += '&name_ingredient=' + encodeURI(ingredientname);
  thePost += '&ingredient_warning=' + encodeURI(ingredientwarning);
  /* Send the category to the server */
  AJAXrequest.onreadystatechange = function () {
    if (AJAXrequest.readyState == 4) {
      if (AJAXrequest.responseText != '0' && (! isNaN(AJAXrequest.responseText)) && AJAXrequest.responseText.length != 0) {
        /* Add the new label list */
        theNewLabel.setAttribute('class','new');
        theNewLabel.innerHTML = '<input id="ingredients[]" name="ingredients[]" type="checkbox" value="' + AJAXrequest.responseText + '" />' + ingredientname;
      	theIngredientsList.appendChild(theNewLabel);
        TWD_JS_showHideObjects('newingredientajaxsaved','none');
        TWD_JS_showHideObjects('newingredientajaxerror','none');        
        TWD_JS_showHideObjects('newingredientajaxsaving','none');
        TWD_JS_showHideObjects('addingredient','none','closedingredient','');
      } else {
        TWD_JS_showHideObjects('newingredientajaxerror','');        
        TWD_JS_showHideObjects('newingredientajaxsaving','none');
        var theErrorPane = TWD_JS_findObj('newingredientajaxerror')
        theErrorPane.innerHTML = '<img src="_skins/default/images/ICONajaxerror_red.gif" />' + AJAXrequest.responseText;
      }
    }
  }
  AJAXrequest.open('POST',theURL,true);
  AJAXrequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');  
  AJAXrequest.send(thePost); 
   
 	/* return true */
	return true;
}





















function SKINK_JS_filebrowser_getfilelist(theURL,theFolder, theDocument) {
  try {
    AJAXrequest2 = new XMLHttpRequest(); /* e.g. Firefox */
  } 
  catch(e) {
    try {
      AJAXrequest2 = new ActiveXObject("Msxml2.XMLHTTP");  /* some versions IE */
    } 
    catch (e) {
      try {
        AJAXrequest2 = new ActiveXObject("Microsoft.XMLHTTP");  /* some versions IE */
      } 
      catch (E) {
        AJAXrequest2 = false;
      }
    }
  }
  var theFileList = TWD_JS_findObj('filelist',theDocument);
  var theFileListLoading = TWD_JS_findObj('filelist_loading',theDocument);
  /* Grab file list */
  if (!AJAXrequest2) {
    alert('This method of viewing file lists is not supported by your browser - please contact the administrator for more information');
    return false;
  }
  AJAXrequest2.onreadystatechange = function () {
    if (AJAXrequest2.readyState == 4) {
      if (AJAXrequest2.status != 200) {
        alert('An error occured with the server connection');
        theFileList.style.display = '';
        theFileListLoading.style.display = 'none';  
        return false;
      }
      theFileList.innerHTML = AJAXrequest2.responseText;
      theFileList.style.display = '';
      theFileListLoading.style.display = 'none';   
    }
  }
  AJAXrequest2.open('GET',theURL + '&ajax=filelist&file='+encodeURI(theFolder),true);
  AJAXrequest2.send(null); 
  
}

function SKINK_JS_filebrowser_changefolder(theURL,theFolder, theDocument) {
  try {
    AJAXrequest = new XMLHttpRequest(); /* e.g. Firefox */
  } 
  catch(e) {
    try {
      AJAXrequest = new ActiveXObject("Msxml2.XMLHTTP");  /* some versions IE */
    } 
    catch (e) {
      try {
        AJAXrequest = new ActiveXObject("Microsoft.XMLHTTP");  /* some versions IE */
      } 
      catch (E) {
        AJAXrequest = false;
      }
    }
  }
  /* Init things */
  var theFileList = TWD_JS_findObj('filelist',theDocument);
  var theFolderName = TWD_JS_findObj('foldername',theDocument);
  var theUploadFolder = TWD_JS_findObj('upload_folder',theDocument);
  var theFileListLoading = TWD_JS_findObj('filelist_loading',theDocument);
  var theFolderList = TWD_JS_findObj('folderlist',theDocument);
  var theFolderListLoading = TWD_JS_findObj('folderlist_loading',theDocument);
   /* Set the images to loading */
  theFileList.style.display = 'none';
  theFileListLoading.style.display = '';
  theFolderList.style.display = 'none';
  theFolderListLoading.style.display = '';          
  /* Set up Ajax */
  AJAXrequest = SKINK_JS_ajaxconnect();
  /* Tell the user if Ajax is not going to work */
  if (!AJAXrequest) {
    alert('This method of viewing file lists is not supported by your browser - please contact the administrator for more information');
    return false;
  }
  /* Grab folder list */
  AJAXrequest.onreadystatechange = function () {
    if (AJAXrequest.readyState == 4) {
      if (AJAXrequest.status != 200) {
        alert('An error occured with the server connection');
        theFolderList.style.display = '';
        theFolderListLoading.style.display = 'none';          
        return false;
      }
      theFolderList.innerHTML = AJAXrequest.responseText;
      theFolderList.style.display = '';
      theFolderListLoading.style.display = 'none';  
      theFolderName.innerHTML = decodeURI(theFolder);       
      theUploadFolder.value = decodeURI(theFolder);       
    }
  }
  AJAXrequest.open('GET',theURL + '&ajax=folderlist&folder='+encodeURI(theFolder),true);
  AJAXrequest.send(null); 

  SKINK_JS_filebrowser_getfilelist(theURL,theFolder,theDocument)  
}



function SKINK_JS_filebrowser_filedetails(theURL) {
  /* Init things */
  var theFileDetails = TWD_JS_findObj('filedetails');
  var theFileDetailsLoading = TWD_JS_findObj('filedetails_loading');
  var theFilename = TWD_JS_findObj('filedetails_name');
  var theFilesize = TWD_JS_findObj('filedetails_size');
  var theFilepreviewimage = TWD_JS_findObj('filedetails_imagepreview');
  var theFileimage = TWD_JS_findObj('filedetails_image');
   /* Set the images to loading */
  theFileDetails.style.display = 'none';
  theFileDetailsLoading.style.display = '';
  theFilepreviewimage.style.display = 'none'
  /* Set up Ajax */
  AJAXrequest = SKINK_JS_ajaxconnect();
  /* Tell the user if Ajax is not going to work */
  if (!AJAXrequest) {
    alert('This method of viewing details is not supported by your browser - please contact the administrator for more information');
    return false;
  }
  /* Get the details from the server */
  AJAXrequest.onreadystatechange = function () {
    if (AJAXrequest.readyState == 4) {
      if (AJAXrequest.status != 200) {
        alert('An error occured with the server connection');
        theFileDetails.style.display = '';
        theFileDetailsLoading.style.display = 'none';        
        return false;
      }
      var blobs = AJAXrequest.responseText.split('&')
      for (i=0;i<blobs.length;i++) {
        details = blobs[i];
        detail = details.split('=');
        if (detail[0] == 'filename') {
          theFilename.innerHTML = decodeURI(detail[1]);
        } else if (detail[0] == 'filesize') {
          theFilesize.innerHTML = decodeURI(detail[1]);          
        } else if (detail[0] == 'fileuri') {
          theFileimage.src = decodeURI(detail[1]);
        } else if (detail[0] == 'filetype') {
          if (decodeURI(detail[1]) == 'image') {
            theFilepreviewimage.style.display = '';           
          }
        }
      }
      theFileDetails.style.display = '';
      theFileDetailsLoading.style.display = 'none';              
    }
  }
  AJAXrequest.open('GET',theURL,true);
  AJAXrequest.send(null); 
  
 	/* return true */
	return true;
}


function SKINK_JS_filebrowser_shoppingcart_images(theFileUrl) {
  var theOpenerTextBox = TWD_JS_findObj('url_image');
  var theOpenerTextBoxPreview = TWD_JS_findObj('url_image_preview');
  theOpenerTextBox.value = theFileUrl;
  theOpenerTextBoxPreview.value = theFileUrl;
  SKINK_JS_popupclose();
}