
var HOME='http://www.PhenixControls.com';
var ver_active = new Array();
function getObject( id )
{
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}

function fullImage(uid, width, height) {
	var win_image_main = getObject("Window_Image");
	var win_image_src = getObject("Window_Image_Src");
	
	win_image_main.style.display = "table";
	
	var IMG = Image(width, height);
	IMG.onload = function() {
		winW = window.innerWidth;
  		winH = window.innerHeight;
  		var top = 0;
  		var scale = 1.0;
  		if( width > winW ) {
  			scale = (winW/width) * 0.9;
  			width *= scale;
  			height *= scale;  			 	
  		}  		
  		
  		if( height > winH ) {
  			scale = (winH/height) * 0.9;
  			width *= scale;
  			height *= scale;
  		}
  		
  		top = winH - height;
  		top = top /2;

		win_image_src.src=IMG.src;
		win_image_src.style.width=width+"px";
		win_image_src.style.height=height+"px";
		win_image_src.style.top = top+"px";
		win_image_src.style.border="4px solid #000";
		
	};
	IMG.src = "/Images/Full/"+uid+".png";
	//
	//win_image_src.src = 
	//win_image_main.style.height = "100%";
	//win_image_src.style.display = "block";
	
	return false;	
}

function fullImageReturn() {
	var win_image_main = getObject("Window_Image");
	var win_image_src = getObject("Window_Image_Src");
	win_image_src.style.border="none";
	win_image_src.style.width="400px";
	win_image_src.style.height="400px";
	win_image_src.src = "/Images/LoadingImage.png";
	win_image_main.style.display = "none";	
	//win_image_src.style.display = "none";
}

var Base64 = (function() {
  function encode_base64(data) {
    var out = "", c1, c2, c3, e1, e2, e3, e4;
    for (var i = 0; i < data.length; ) {
       c1 = data.charCodeAt(i++);
       c2 = data.charCodeAt(i++);
       c3 = data.charCodeAt(i++);
       e1 = c1 >> 2;
       e2 = ((c1 & 3) << 4) + (c2 >> 4);
       e3 = ((c2 & 15) << 2) + (c3 >> 6);
       e4 = c3 & 63;
       if (isNaN(c2))
         e3 = e4 = 64;
       else if (isNaN(c3))
         e4 = 64;
       out += tab.charAt(e1) + tab.charAt(e2) + tab.charAt(e3) + tab.charAt(e4);
    }
    return out;
  }

  function decode_base64(data) {
    var out = "", c1, c2, c3, e1, e2, e3, e4;
    for (var i = 0; i < data.length; ) {
      e1 = tab.indexOf(data.charAt(i++));
      e2 = tab.indexOf(data.charAt(i++));
      e3 = tab.indexOf(data.charAt(i++));
      e4 = tab.indexOf(data.charAt(i++));
      c1 = (e1 << 2) + (e2 >> 4);
      c2 = ((e2 & 15) << 4) + (e3 >> 2);
      c3 = ((e3 & 3) << 6) + e4;
      out += String.fromCharCode(c1);
      if (e3 != 64)
        out += String.fromCharCode(c2);
      if (e4 != 64)
        out += String.fromCharCode(c3);
    }
    return out;
  }

  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  return { encode:encode_base64, decode:decode_base64 };
})();



function setVersion(id, des) {
	var aid=id.split("");
	var ades=des.split("|");
	var pos=0;
	var new_active =new Array();
	for(var x=0; x<ver_active.length; x++) {
		var pid = ver_active[x][0];
		var conflicts = false;
		for(var y=0; y<aid.length; y++) {
			if( aid[y]!="_" && pid[y]!="_" ) {
				conflicts=true;
			}	
		}
		if( !conflicts) new_active[pos++]=ver_active[x];	
	}
	new_active[pos++]=new Array(aid, ades);
	ver_active=new_active;
	
	for(var x=0; x<ver_active.length; x++) {
		
		for(var y=0; y<ver_active[x][0].length; y++) {
			if( x==0 ) getObject('version_id_'+y).innerHTML="";
			if( ver_active[x][0][y] != "_" ) {
				getObject('version_id_'+y).innerHTML=ver_active[x][0][y]
			}
		}
		for(var y=0; y<ver_active[x][1].length; y++) {
			if( x==0 ) getObject('version_description_'+y).innerHTML="";
			if( ver_active[x][1][y] != "" ) {
				getObject('version_description_'+y).innerHTML=ver_active[x][1][y]
			}
		}
	}
}




