//JS Functions @0-32619B8E
var isNN = (navigator.appName.indexOf("Netscape") != -1);
var isIE = (navigator.appName.indexOf("Microsoft") != -1);
var IEVersion = (isIE ? getIEVersion() : 0);
var NNVersion = (isNN ? getNNVersion() : 0);
var EditableGrid = false;
var disableValidation = false;

function ccsShowError(control, msg)
{
  alert(msg);
  control.focus();
  return false;
}

function getNNVersion()
{
  var userAgent = window.navigator.userAgent;
  var isMajor = parseInt(window.navigator.appVersion);
  var isMinor = parseFloat(window.navigator.appVersion);
  if (isMajor == 2) return 2;
  if (isMajor == 3) return 3;
  if (isMajor == 4) return 4;
  if (isMajor == 5) return 6;
  return isMajor;
}

function getIEVersion()
{
  var userAgent = window.navigator.userAgent;
  var MSIEPos = userAgent.indexOf("MSIE");
  return (MSIEPos > 0 ? parseInt(userAgent.substring(MSIEPos+5, userAgent.indexOf(".", MSIEPos))) : 0);
}

function inputMasking(evt)
{
  if (isIE && IEVersion > 4)
  {
    if (window.event.altKey) return false;
    if (window.event.ctrlKey) return false;
    if (typeof(this.ccsInputMask) == "string")
    {
      var mask = this.ccsInputMask;
      var keycode = window.event.keyCode;
      this.value = applyMask(keycode, mask, this.value);
    }
    return (window.event.keyCode==13?true:false);
  } else if (isNN && NNVersion<6)
  {
    if (evt.ALT_MASK) return false;
    if (evt.CONTROL_MASK) return false;
    if (typeof(this.ccsInputMask) == "string")
    {
      var mask = this.ccsInputMask;
      var keycode = evt.which;
      this.value = applyMask(keycode, mask, this.value);
    }
    return (evt.which==13?true:false);
  } else if (isNN && NNVersion==6)
  {
    if (evt.altKey) return false;
    if (evt.ctrlKey) return false;
    if (typeof(this.ccsInputMask) == "string")
    {
      var mask = this.ccsInputMask;
      this.value = applyMaskToValue(mask, this.value);
    }
    return (evt.which==13?true:false);
  } else
    return true;
}

function applyMaskToValue(mask, value)
{
  var oldValue = String(value);
  var newValue = "";
  for (var i=0; i<oldValue.length; i++)
  {
    newValue = applyMask(oldValue.charCodeAt(i), mask, newValue);
  }
  return newValue;
}

function applyMask(keycode, mask, value)
{
  var digit = (keycode >= 48 && keycode <= 57);
  var plus = (keycode == 43);
  var dash = (keycode == 45);
  var space = (keycode == 32);
  var uletter = (keycode >= 65 && keycode <= 90);
  var lletter = (keycode >= 97 && keycode <= 122);
  
  var pos = value.length;
  switch(mask.charAt(pos))
  {
    case "0":
      if (digit)
        value += String.fromCharCode(keycode);
      break;
    case "L":
      if (uletter || lletter)
        value += String.fromCharCode(keycode);
    default:
      var isMatchMask = (String.fromCharCode(keycode) == mask.charAt(pos));
      while (pos < mask.length && mask.charAt(pos) != "0")
        value += mask.charAt(pos++);
      if (!isMatchMask && pos < mask.length)
        value = applyMask(keycode, mask, value);
  }  
  return value;
}

function validate_control(control)
{
/*
ccsCaption - string
ccsErrorMessage - string

ccsRequired - boolean
ccsMinLength - integer
ccsMaxLength - integer
ccsRegExp - string

ccsValidator - validation function

ccsInputMask - string
*/
  if (disableValidation) return true;
  var errorMessage = control.ccsErrorMessage;
  var customErrorMessage = (typeof(errorMessage) != "undefined");
   
  if (typeof(control.ccsRequired) == "boolean" && control.ccsRequired)
    if (control.value == "")
      return ccsShowError(control, customErrorMessage ? errorMessage :
        "The value in field " + control.ccsCaption + " is required.");

  if (typeof(control.ccsMinLength) == "number")
    if (control.value != "" && control.value.length < parseInt(control.ccsMinLength))
      return ccsShowError(control, customErrorMessage ? errorMessage :
        "The length in field " + control.ccsCaption + " can't be less than " + parseInt(control.ccsMinLength) + " symbols.");

  if (typeof(control.ccsMaxLength) == "number")
    if (control.value != "" && control.value.length > parseInt(control.ccsMaxLength))
      return ccsShowError(control, customErrorMessage ? errorMessage :
        "The length in field " + control.ccsCaption + " can't be greater than " + parseInt(control.ccsMaxLength) + " symbols.");

  if (typeof(control.ccsRegExp) == "string")
    if (control.value != "" && (control.value.search(new RegExp(control.ccsRegExp, "i")) == -1))
      return ccsShowError(control, customErrorMessage ? errorMessage :
        "The value in field " + control.ccsCaption + " is not valid.");

  if (typeof(control.ccsDateFormat) == "string")
  {
    if (control.value != "" && !checkDate(control.value, control.ccsDateFormat))
      return ccsShowError(control, customErrorMessage ? errorMessage :
        "The value in field " + control.ccsCaption + " is not valid. Use the following format: "+control.ccsDateFormat);
  }

  if (typeof(control.ccsValidator) == "function")
    if (!control.ccsValidator())
      return ccsShowError(control, customErrorMessage ? errorMessage :
        "The value in field " + control.ccsCaption + " is not valid.");

  return true;
}

function stringToRegExp(string, arg)
{
  var str = String(string);
  str = str.replace(/\\/g,"\\\\");
  str = str.replace(/\//g,"\\/");
  str = str.replace(/\./g,"\\.");
  str = str.replace(/\(/g,"\\(");
  str = str.replace(/\)/g,"\\)");
  str = str.replace(/\[/g,"\\[");
  str = str.replace(/\]/g,"\\]");
  return str;
}

function checkDate(dateValue, dateFormat)
{
  var DateMasks = new Array(
                    new Array("MMMM", "[a-z]+"),
                    new Array("mmmm", "[a-z]+"),
                    new Array("yyyy", "[0-9]{4}"),
                    new Array("MMM", "[a-z]+"),
                    new Array("mmm", "[a-z]+"),
                    new Array("HH", "([0-1][0-9]|2[0-4])"),
                    new Array("hh", "(0[1-9]|1[0-2])"),
                    new Array("dd", "([0-2][0-9]|3[0-1])"),
                    new Array("MM", "(0[1-9]|1[0-2])"),
                    new Array("mm", "(0[1-9]|1[0-2])"),
                    new Array("yy", "[0-9]{2}"),
                    new Array("nn", "[0-5][0-9]"),
                    new Array("ss", "[0-5][0-9]"),
                    new Array("w", "[1-7]"),
                    new Array("d", "([1-9]|[1-2][0-9]|3[0-1])"),
                    new Array("y", "([1-2][0-9]{0,2}|3([0-5][0-9]|6[0-5]))"),
                    new Array("H", "(00|0?[1-9]|1[0-9]|2[0-4])"),
                    new Array("h", "(0?[1-9]|1[0-2])"),
                    new Array("M", "(0?[1-9]|1[0-2])"),
                    new Array("m", "(0?[1-9]|1[0-2])"),
                    new Array("n", "[0-5]?[0-9]"),
                    new Array("s", "[0-5]?[0-9]"),
                    new Array("q", "[1-4]")
                  );
  var regExp = "^"+stringToRegExp(dateFormat)+"$";
  for (var i=0; i<DateMasks.length; i++)
  {
    regExp = regExp.replace(DateMasks[i][0], DateMasks[i][1]);
  }
  var regExp = new RegExp(regExp,"i");
  return String(dateValue).search(regExp)!=-1;
}

function validate_row(rowId, form)
{
  var result = true;
  var isInsert = false;
  if (disableValidation) return true;
  if(typeof(eval(form + "EmptyRows")) == "number")
    if(eval(form + "Elements").length - rowId <= eval(form + "EmptyRows"))
      isInsert = true;
    for (var i = 0; i < eval(form + "Elements")[rowId].length && isInsert; i++)
      isInsert = GetValue(eval(form + "Elements")[rowId][i]) == "";
  if(isInsert) return true;

  if(typeof(eval(form + "DeleteControl")) == "number")
    {
      var control = eval(form + "Elements")[rowId][eval(form + "DeleteControl")];
      if(control.type == "checkbox")
        if(control.checked == true ) return true;
      if(control.type == "hidden")
        if(control.value != "" ) return true;
    }

  for (var i = 0; i < eval(form + "Elements")[rowId].length && (result = validate_control(eval(form + "Elements")[rowId][i])); i++);
  return result;
}

function GetValue(control) {
    if (typeof(control.value) == "string") {
        return control.value;
    }
    if (typeof(control.tagName) == "undefined" && typeof(control.length) == "number") {
        var j;
        for (j=0; j < control.length; j++) {
            var inner = control[j];
            if (typeof(inner.value) == "string" && (inner.type != "radio" || inner.status == true)) {
                return inner.value;
            }
        }
    }
    else {
        return GetValueRecursive(control);
    }
    return "";
}

function GetValueRecursive(control)
{
    if (typeof(control.value) == "string" && (control.type != "radio" || control.status == true)) {
        return control.value;
    }
    var i, val;
    for (i = 0; i<control.children.length; i++) {
        val = GetValueRecursive(control.children[i]);
        if (val != "") return val;
    }
    return "";
}


function validate_form(form)
{
  var result = true;
  if (disableValidation) return true;
  if(typeof(form) == "object" && document.getElementById(form.name + "Elements")) {
    if (typeof(eval(form.name + "Elements")) == "object") 
      for (var j = 0; j < eval(form.name + "Elements").length && result; j++) result = validate_row(j, form.name);
    else 
      for (var i = 0; i < form.elements.length && (result = validate_control(form.elements[i])); i++);
  }else if(typeof(form) == "string" && document.getElementById(form.name + "Elements"))
  {
    if(typeof(eval(form + "Elements")) == "object"){
      for (var j = 0; j < eval(form + "Elements").length && result; j++)
        result = validate_row(j, form);
    }
  }else if (typeof(form) == "object")
          for (var i = 0; i < form.elements.length && (result = validate_control(form.elements[i])); i++);
        else	
          for (var i = 0; i < document.forms[form].elements.length && (result = validate_control(document.forms[form].elements[i])); i++);
  return result;
}

function forms_onload()
{
  var forms = document.forms;
  var i, j, elm, form;
  for(i = 0; i < forms.length; i++)
  {
    form = forms[i];
    if (typeof(form.onLoad) == "function") form.onLoad();
    for (j = 0; j < form.elements.length; j++)
    {
      elm = form.elements[j];
      if (typeof(elm.onLoad) == "function") elm.onLoad();
    }
  }
  return true;
}

//
// If element exist than bind function func to element on event.
// Example: check_and_bind('document.NewRecord1.Delete1','onclick',page_NewRecord1_Delete1_OnClick);
//
function check_and_bind(element,event,func) {
  if (eval(element)) {
    eval(element+'.'+event+'='+func);
  }
}

//End JS Functions

var cTRColorOn = '#87CEEB';
var cTRColorOff = '#B8B8B8';
var cLight = '#D0D0D0';
////var cLight = '#FFFFFF';
//var cLight = '#BEBEBE';
var cDark = '#686868';
////var cDark = '#698BB7';
//var cDark = '#1A222D';
//var cFrame = '#e5f4ff';
//var cFrame = '#698BB7';
//var cFrame = '#BED3EF';
var cFrame = '#5E80AC';
var isIEBrowser = (navigator.userAgent.toLowerCase().indexOf('msie') != -1)?true:false;

function onCM() {
	return false;
}

function TRColorOn( oObject) {
	oObject.bgColor = cTRColorOn;
	oObject.style.cursor = "hand";
	return true;
}

function TRColorOff( oObject) {
	oObject.bgColor = cTRColorOff;
//	oObject.style.cursor = "default";
	return true;
}

function ionmouseover( oObject, cStatus) {
	var nWidth = oObject.style.borderTopWidth
	oObject.style.borderTop = cLight
	oObject.style.borderLeft = cLight
	oObject.style.borderBottom = cDark
	oObject.style.borderRight = cDark
	oObject.style.borderTopWidth = nWidth
	oObject.style.borderLeftWidth = nWidth
	oObject.style.borderBottomWidth = nWidth
	oObject.style.borderRightWidth = nWidth
	oObject.style.borderStyle = 'outset'
	oObject.style.position = 'relative'
	oObject.style.left = 0
	oObject.style.top = 0
	oObject.style.filter = 'alpha(opacity=100)';
	window.status = cStatus
}

function ionmouseout( oObject, cStatus) {
	var nWidth = oObject.style.borderTopWidth
	oObject.style.borderTop = cLight
	oObject.style.borderLeft = cLight
	oObject.style.borderBottom = cDark
	oObject.style.borderRight = cDark
	oObject.style.borderTopWidth = nWidth
	oObject.style.borderLeftWidth = nWidth
	oObject.style.borderBottomWidth = nWidth
	oObject.style.borderRightWidth = nWidth
	oObject.style.borderStyle = 'outset'
	oObject.style.position = 'relative'
	oObject.style.left = 0
	oObject.style.top = 0
	oObject.style.filter = 'alpha(opacity=80)';
	window.status = cStatus
}


function ionmouseup( oObject, cLink, cStatus) {

	if (event.button == 1) {
		var nWidth = oObject.style.borderTopWidth
		oObject.style.borderTop = cLight
		oObject.style.borderLeft = cLight
		oObject.style.borderBottom = cDark
		oObject.style.borderRight = cDark
		oObject.style.borderTopWidth = nWidth
		oObject.style.borderLeftWidth = nWidth
		oObject.style.borderBottomWidth = nWidth
		oObject.style.borderRightWidth = nWidth
		oObject.style.borderStyle = 'outset'
		oObject.style.position = 'relative'
		oObject.style.left = 0
		oObject.style.top = 0
		oObject.style.filter = 'alpha(opacity=100)';
		window.status = cStatus
		if (cLink != '') {
			document.location.href = cLink
		}
		window.status = cStatus
	}
}

function ionmousedown( oObject, cStatus) {

	if (event.button == 1) {
		var nWidth = oObject.style.borderTopWidth
		oObject.style.borderTop = cDark
		oObject.style.borderLeft = cDark
		oObject.style.borderBottom = cLight
		oObject.style.borderRight = cLight
		oObject.style.borderTopWidth = nWidth
		oObject.style.borderLeftWidth = nWidth
		oObject.style.borderBottomWidth = nWidth
		oObject.style.borderRightWidth = nWidth
		oObject.style.borderStyle = 'inset'
		oObject.style.position = 'relative'
		oObject.style.left = 1
		oObject.style.top = 1
		oObject.style.filter = 'alpha(opacity=100)';
		window.status = cStatus
	}
}

function funReload() {

//	if (!document.layers && !document.all)
//		return;
	var runTime = new Date();
	var years = runTime.getYear();
	var months = runTime.getMonth() + 1;
	var days = runTime.getDate();
	var hours = runTime.getHours();
	var minutes = runTime.getMinutes();
	var seconds = runTime.getSeconds();
	var mseconds = runTime.getMilliseconds() + 49;

	if (minutes <= 9) {
		minutes = "0" + minutes;
	}

	if (seconds <= 9) {
		seconds = "0" + seconds;
	}

	if (months <= 9) {
		months = "0" + months;
	}

	if (days <= 9) {
		days = "0" + days;
	}
	movingtime = hours + ":" + minutes + ":" + seconds;
	movingdate = years + "." + months + "." + days;

	document.all.keepalive.style.filter = "alpha(opacity=0)";
	document.all.imgStatus.src = "Themes/HourGlass.gif";

	document.keepalive.location.href = "KeepAlive.asp";

	setTimeout("funReload()", 300000)
}

function MakeLoginStatus() {
	document.write( "<img style=\"POSITION: absolute; TOP: 0%; RIGHT: 0%;\" src=\"Themes/HourGlass.gif\" name=\"imgStatus\" onmouseover=\"window.status='Status zalogowania'\" onmouseout=\"window.status=''\" title=\"Status zalogowania\">\n");
	document.write("<iframe style=\"FILTER: alpha(opacity=0); POSITION: absolute; TOP: 0%; RIGHT: 0%;\" width=\"16\" height=\"16\" frameborder=\"0\" border=\"0\" name=\"keepalive\" src=\"KeepAlive.asp\" scrolling=\"no\" application=\"no\" onmouseover=\"window.status='Status zalogowania'\" onmouseout=\"window.status=''\" title=\"Status zalogowania\"></iframe>\n");
}

function OpenHelp(cHelpID) {

	if(cHelpID == "empty") {
		return true;
	}
}

function PrintIt(cPrintID) {

	if(cPrintID == "empty") {
		return true;
	}
}

function SetNavButtons() {
	document.all.navbuttons.style.left = document.body.offsetWidth - 160 + "px";
	document.all.navbuttons.style.width = "120px";
	document.all.navbuttons.style.top = "80px";
	document.all.navbuttons.style.right = "10px";
}

function SetRightBGImage() {
	document.all.rightbgimage.style.left = document.body.offsetWidth - 305 + "px";
	document.all.rightbgimage.style.width = "285px";
	document.all.rightbgimage.style.top = "0px";
	document.all.rightbgimage.style.right = "0px";
}

function controlPress(eventObj, iMaxLength)
{
	var sValue, iCode;
	
	if(checkIfIEBrowser()) {
		sValue = eventObj.srcElement.value;
		iCode = eventObj.keyCode;
	} else {
		sValue = eventObj.target.value;
		iCode = eventObj.which;
	}
	
	if(!( iCode == 9 || iCode == 13 || iCode == 46 || iCode == 8 || iCode == 144 || iCode >= 35 && iCode <=40 || iCode == 20 || iCode == 27 || iCode == 16 || eventObj.ctrlKey || eventObj.altKey ) ) {

		if(!( iCode >= 48 && iCode <= 57 || iCode >= 96 && iCode <= 105  )) {
//			alert("W tym polu można wpisywać tylko liczby!");
			
			if(checkIfIEBrowser()) {
				eventObj.srcElement.value = sValue;
			} else {
				eventObj.target.value = sValue;
			}
			return false;
		} else {
			return true;
		}	
	}
}

function checkIfIEBrowser(){
	return (isIEBrowser)?true:false;
}

function jumpTo(page){
	if(self==parent){document.location=page};
}

function __getServerTime() {
	var x = new Date();
	return x.getTime();
}

function markCheck(objID) {
	var myObj = document.getElementById(objID);
	if(myObj.checked) {
		myObj.checked = false;
	} else {
		myObj.checked = true;
	}
}

function pageSetTimeFrameSize() {
	var oFrame = document.getElementById("timeFrame");
	if(oFrame.contentDocument) {
		
		if(oFrame.contentDocument.all.timeTable) {
			oFrame.height = oFrame.contentDocument.all.timeTable.offsetHeight;
		}
	} else if(oFrame) {
		
		if(document.frames("timeFrame").document.all.timeTable) {
			document.all.timeFrame.height = document.frames("timeFrame").document.all.timeTable.offsetHeight;
		}
	}
}

function setTimeFrameSize() {
	var oFrame = window.parent.document.getElementById("timeFrame");
	
	if(oFrame) {
		
		if(oFrame.contentDocument) {
			
			if(oFrame.contentDocument.all.timeTable) {
				oFrame.height = oFrame.contentDocument.all.timeTable.offsetHeight;
			}
		} else {
			
			if(window.parent.document.frames("timeFrame").document.all.timeTable) {
				window.parent.document.all.timeFrame.height = window.parent.document.frames("timeFrame").document.all.timeTable.offsetHeight;
			}
		}
	}
}

function simpleObjFind(objId) {
	var oObj	
	
	if(document.getElementById) {
		oObj = document.getElementById(objId);
	} else {
		oObj = document.all[objId];
	}
	return oObj;
}

function objWrite( objId, input)
{
	var obj_x = simpleObjFind(objId);
	input = input;
	if (obj_x && obj_x.innerHTML) 
	{
		obj_x.innerHTML = input;
	}
	else if (obj_x && obj_x.document) 
	{
		obj_x.document.writeln(input);
		obj_x.document.close();
	}
}

function countChars(eventObj, iMaxLength) {
	var sValue, iCode, nCharsLeft, retVal;
	
	if(checkIfIEBrowser()) {
		sValue = eventObj.srcElement.value;
		iCode = eventObj.keyCode;
	} else {
		sValue = eventObj.target.value;
		iCode = eventObj.which;
	}
	nCharsLeft = iMaxLength - sValue.length;
	
	if(!( iCode == 7 || iCode == 8 || iCode == 9 || iCode == 13 || iCode == 16 || iCode == 20 || iCode == 27 || iCode >= 35 && iCode <=40 || iCode == 46 || iCode == 144 || eventObj.ctrlKey && (iCode == 88 || iCode == 89 || iCode == 90 || iCode == 120 || iCode == 121 || iCode == 122) || eventObj.altKey ) ) {
		
		if(nCharsLeft <= 0) {
			nCharsLeft = 0;
			
			if(checkIfIEBrowser()) {
				eventObj.srcElement.value = sValue;
			} else {
				eventObj.target.value = sValue;
			}
			retVal = false;
		} else {
			retVal = true;
		}
	} else {
		retVal = true;
	}
	return retVal;
}

function showCountChars(eventObj, iMaxLength, oObj, cLeftId) {
	var sValue, iCode, nCharsLeft, nDispCharsLeft, oLeftObj, retVal;
	
	if(checkIfIEBrowser()) {
		sValue = eventObj.srcElement.value;
		iCode = eventObj.keyCode;
	} else {
		sValue = eventObj.target.value;
		iCode = eventObj.which;
	}
	oLeftObj = simpleObjFind(cLeftId);
	nCharsLeft = iMaxLength - sValue.length;

	if(oObj.value.length == 0) {
		nDispCharsLeft = iMaxLength;
	} else if(oObj.value.length > 0) {
		nDispCharsLeft = (iMaxLength - oObj.value.length);
	}

	if(nDispCharsLeft <= 0) {
		nDispCharsLeft = 0;
	} else if(nDispCharsLeft > iMaxLength) {
		nDispCharsLeft = iMaxLength;
	}
	
	if(oLeftObj) {
		oLeftObj.value = nDispCharsLeft;
	}
	
	if(nDispCharsLeft == 0) {
		
		if(checkIfIEBrowser()) {
			eventObj.srcElement.value = sValue.substr( 0, iMaxLength);
		} else {
			eventObj.target.value = sValue.substr( 0, iMaxLength);
		}
	}
	return true;
}

function NoSelect() {
	
	if(browserType()!="OP" && browserType()!="FF") {
		document.selection.empty();
	}
	return false;
}

function browserType() {
	var d=document;
	var NS7=(!d.all&&d.getElementById);
	var NS4=(!d.getElementById);
	var IE5=(!NS4&&!NS7&&(navigator.userAgent.indexOf('MSIE 5.0')!=-1||navigator.userAgent.indexOf('MSIE 5.2')!=-1));
	var IE6=(!NS4&&!NS7&&(navigator.userAgent.indexOf('MSIE 6.0')!=-1));
	var FF=(navigator.userAgent.indexOf('Firefox')!=-1);
	var IE5p5=(!NS4&&!NS7&&navigator.userAgent.indexOf('MSIE 5.5')!=-1);
	var NS6=(NS7&&navigator.userAgent.indexOf('Netscape6')!=-1);
	var NS8=(NS7&&navigator.userAgent.indexOf('Netscape/8')!=-1);
	var SAF=navigator.userAgent.indexOf('Safari')!=-1;
	p=navigator.userAgent.indexOf('Opera');
	var OP=(p!=-1);
	
	if(p>-1) {
		p=navigator.userAgent.charAt(p+6);
		if(p>6)NS7=1;else NS4=1;
	}
	var ifr=(!NS7&&!NS4&&!IE5&&!IE5p5);
	var quirk=(d.compatMode&&d.compatMode=="BackCompat")||IE5||IE5p5;
	var retVal;
	
	if(OP) {
		retVal = "OP";
	} else if(FF) {
		retVal = "FF";
	} else if(NS4) {
		retVal = "NS4";
	} else if(IE5) {
		retVal = "IE5";
	} else if(IE5p5) {
		retVal = "IE5p5";
	} else if(NS6) {
		retVal = "NS6";
	} else if(SAF) {
		retVal = "SAF";
	} else if(IE6) {
		retVal = "IE6";
	} else if(NS8) {
		retVal = "NS8";
	} else if(NS7) {
		retVal = "NS7";
	} else {
		retVal = "Other";
	}
	return retVal;
}

function loadSelectedImage( idImg, idImagesLinks, oSelect) {
	var oImg, oImagesLinks, aLinks, nPos;
	oImg = simpleObjFind(idImg);
	oImagesLinks = simpleObjFind(idImagesLinks);
	
	if(!oImg) {
		return true;
	} else if(!oImagesLinks) {
		return true;
	} else if(!oSelect) {
		return true;
	}
	aLinks = oImagesLinks.value.split(";");
	nPos = oSelect.selectedIndex - 1;
	
	if((aLinks.length > 0) && (nPos >= 0) && (nPos < aLinks.length)) {
		oImg.src = aLinks[nPos];
	} else {
		oImg.src = "/images/empty.gif";
	}
	return true;
}

function makeUpperCase( oObj) {
	oObj.value = oObj.value.toUpperCase();
	return true;
}

function openWin(url, title, width, height) {  
	if (!width) {
		width = 460;
	}
	if (!height) {
		height = 180;
	}
	if (!document.all) {
		window.open(url,title, "width=" + width + ",height=" + height);
	} else {
		window.showModalDialog(url, self, "dialogHeight:" + height + "px;dialogWidth:" + width + "px;status:no;help:no;resizable:yes");
	}
}

function QueryString(opt,opts) {
	var keyloc, nextkey, start, optval;
	if(!opts) {
		opts = location.search;
	}
	keyloc = opts.indexOf("&" + opt + "=");
	
	if(keyloc == -1) {
		keyloc = opts.indexOf("?" + opt + "=");
	}
	
	if (keyloc == -1) {
		return "";
	}
	nextkey = opts.indexOf("&",keyloc+1);
	
	if (nextkey == -1) {
		nextkey = opts.length;
	}
	
	if (nextkey < keyloc) {
		return "";
	}
	sval = keyloc+2+opt.length;
	optval = plustospace(unescape(opts.substring(sval,nextkey)));
	return optval;
}

function plustospace(txt) {
	
	if (txt == "") {
		return txt;
	}
	var newtxt = "";
	var pos = 0;
	var prev = 0;
	var done = false;
	var tmp;
	
	while (!done) {
		pos = txt.indexOf("+",prev);
		
		if (prev >= txt.length) {
			done = true;
		} else if (pos == 0) {
			prev=1;
			newtxt += " ";
		} else if ((pos < 0) || (pos == "")) {
			done = true;
		} else {
			if (pos>prev) {
				newtxt += txt.substring(prev,pos);
			}
			newtxt += " ";
			prev = pos + 1;
		}
	}
	newtxt += txt.substring(prev,txt.length);
	return newtxt;
}

function setDownload() {
	var oFrame, fileID;
	fileID = QueryString("file");
	if(fileID && fileID != "") {
		oFrame = simpleObjFind("downloadFrame");
		if(oFrame) {
			if(oFrame.location) {
				oFrame.location = "../Downloads/download.php?file=" + fileID;
			} else if(oFrame.src) {
				oFrame.src = "../Downloads/download.php?file=" + fileID;
			}
		}
	}
}

function setDownloadSrc() {
	var fileID, retVal;
	fileID = QueryString("file");
	if(fileID && fileID != "") {
		retVal = "../Downloads/download.php?file=" + fileID;
	}
	return retVal;
}

function showInfoPicture(picPos) {
	if(picPos) {
		picturewindow = window.open("/Info/BigPicture.asp?picID="+picPos, "biginfopic", config="height=640,width=820,top=100,left=100,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,directories=no,status=no");
		if(!picturewindow.closed) {
			picturewindow.focus();
		}
	}
}

function autoTab(input,len, e, pass) {
	var keyCode = (isNN) ? e.which : e.keyCode; 
	//var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,35,36,37,38,39,40,46];
	var filter = [0,8,9,16,17,18,27,35,36,37,38,39,40,46,67];
	if(input.value.length >= len && !containsElement(filter,keyCode)) {
		input.value = input.value.toUpperCase().slice(0, len);
		if(pass) {
			//input.form[(getIndex(input)+1) % input.form.length].focus();
			input.form[(getIndex(input)+1)].focus();
		}
	}
	
	function containsElement(arr, ele) {
		var found = false, index = 0;
		while(!found && index < arr.length) {
			if(arr[index] == ele) {
				found = true;
			} else {
				index++;
			}
		}
		return found;
	}
	
	function getIndex(input) {
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1) {
			if (input.form[i] == input) {
				index = i;
			} else {
				i++;
			}
		}
		return index;
	}
	return true;
}
