var C1Server = "pro.corbis.com";
//var C1Server = "devc1web4";

//the url to load into the control frame when we're done
var bounceBackURL = "http://" + document.location.host +  "/pro/showcase/launchAddMediaConf.asp?t=";

function addMedia(imageID, containerType){
	//alert("Container type: " + containerType + "  imageID:  " + imageID);
	var url = "http://" + C1Server + "/creative/addmedia.asp?addTo=" + containerType + "&corbisID=" + imageID + "&redirect=" + hexCode(bounceBackURL + containerType);
	parent.control.document.location = url;
	//window.document.location = url;
	//alert(url);
}

function hexnib(d) {
   if(d<10) return d; else return String.fromCharCode(65+d-10);
}

function hexCode(url) {
      var result="";
      for(var i=0;i<url.length;i++) {
         var cc=url.charCodeAt(i);
         var hex=hexnib((cc&240)>>4)+""+hexnib(cc&15);
         result+="%"+hex;
      }
      return result;
}
