﻿function changeSize(width, height) {            			
    retrieveElement("UCPreviewNonStudio1_imgCustomDesigns").width = width;
    retrieveElement("UCPreviewNonStudio1_imgCustomDesigns").height = height;
}

function changeImageNonStudio(url, side) {
    retrieveElement("UCPreviewNonStudio1_imgCustomDesigns").src = url;
    if (side=="A") {
        if (retrieveElement("hplEditSideA")) 	            
            retrieveElement("UCPreviewNonStudio1_hplPreviewEdit").href = retrieveElement("hplEditSideA").href;	            
    } else {
        if (retrieveElement("hplEditSideB")) 	            
            retrieveElement("UCPreviewNonStudio1_hplPreviewEdit").href = retrieveElement("hplEditSideB").href;	            
    }	        	                
}

function changeImageItemStructure(url, side) {
    retrieveElement("UCPreviewItemStructure1_imgDesigns").src = url;    
    if (side=="A") {
        //retrieveElement("UCPreviewItemStructure1_hplPreviewSideA").href = "";
    } else {
        //retrieveElement("UCPreviewItemStructure1_hplPreviewSideB").href = "";    
    }    
}
function replaceDDLOptions(source, destination){
    var selectBox = document.getElementById(destination);
    var selectBox2 = document.getElementById(source)
    if (selectBox != null) {
      // blow away any option elements that exist
      selectBox.innerHTML = "";
      // loop through and add the list items      
      for (var i=0; i < selectBox2.length; i++) {
        var opt = document.createElement("option");
        opt.value = selectBox2.options[i].value;
        opt.innerHTML = selectBox2.options[i].text;
        selectBox.appendChild(opt);
      }
    }    
}

function changeElementText(text, destination) {           			
    var selectBox = document.getElementById(destination);
    if (selectBox != null){
        selectBox.value = text;
    }
} 

function pageRedirect(destination, category) {
    //this function is for paper select image onclick
        
    var strCurrent=(location.href);
    var strDest=destination;  
    var boolCategory = category; 

    if (Boolean(boolCategory)) { //true if category is not 0
        if (strCurrent.indexOf('_') != -1){     
            //if current url contains "_[stuff]", need to copy that and append to destination url.
            strDest = strDest + strCurrent.substring(strCurrent.indexOf('_'));
        }    
    }
    parent.location = strDest;    
}