/*function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=4)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
*/
/*
function event_right() {
        if (event.button == 2 || event.button == 3)
            alert("Materials posted are legally copyrighted. \n  We prohibit any outside source to use.");
    }
document.onmousedown = event_right; 
*/
/*
 function handleKeyPress(evt) {  
   var nbr;  
   var nbr = (window.event)?event.button:evt.button;  
   if (nbr == 2 || nbr == 3){
	   alert("Materials posted are legally copyrighted. \n  We prohibit any outside source to use.");
	   return false;  
   }
 }  
  document.onmousedown= handleKeyPress
*/
function checkBox(objName)
{
	var checkbox = document.all(objName);

	var returnValue = '';
	var j=0;

	if(checkbox == undefined) return '';
	
	if(checkbox.length != undefined)
	{
		for (var i=0;i<checkbox.length;i++)
		{
			if (checkbox[i].checked) {
				j++;
				returnValue = returnValue + checkbox[i].value + ",";
			}
		}
		returnValue = returnValue.substring( 0, returnValue.length-1);
	}
	else
	{
		if(checkbox.checked){
			returnValue = checkbox.value;
		}
	}	
	return returnValue;
}

function select_all(objName1, objName2)
	{
		var checkbox = document.all(objName1);

		var chk_confirm = document.all(objName2);
		if(chk_confirm == undefined) return;

		if(checkbox.checked == true){
			if( chk_confirm.length != undefined){
				for (var i=0;i<chk_confirm.length;i++)
				{
					chk_confirm[i].checked = true;
				}
				return;
			}
			else{
				chk_confirm.checked = true;
			}
		}
		else{
			if( chk_confirm != undefined && chk_confirm.length != undefined){
				for (var i=0;i<chk_confirm.length;i++)
				{
					chk_confirm[i].checked = false;
				}
				return;
			}
			else{
				chk_confirm.checked = false;
			}
		}
	}

function getFormElementsAsString( formId )
{
	var sFormData = "";
	var oForm;
	oForm = (document.getElementById(formId) || document.forms[formId]);

	var oElement, oName, oValue, oDisabled;
	var hasSubmit = false;

	// Iterate over the form elements collection to construct the
	// label-value pairs.
	for (var i=0; i<oForm.elements.length; i++)
	{
		oElement = oForm.elements[i];
		oDisabled = oForm.elements[i].disabled;
		oName = oForm.elements[i].name;
		oValue = oForm.elements[i].value;

		// Do not submit fields that are disabled or
		// do not have a name attribute value.
		if( !oDisabled && oName )
		{
			switch( oElement.type )
			{
				case 'select-one':
				case 'select-multiple':
					for(var j=0; j<oElement.options.length; j++)
					{
						if( oElement.options[j].selected )
						{
							if( window.ActiveXObject )
							{
								sFormData += encodeURIComponent(oName) + '=' +
								encodeURIComponent(oElement.options[j].attributes['value'].specified?oElement.options[j].value:oElement.options[j].text) + '&';
							}
							else
							{
								sFormData += encodeURIComponent(oName) + '=' +
								encodeURIComponent(oElement.options[j].hasAttribute('value')?oElement.options[j].value:oElement.options[j].text) + '&';
							}
						}
					}
				break;
				case 'radio':
				case 'checkbox':
					if( oElement.checked )
					{
						sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
					}
				break;
				case 'file':
					// stub case as XMLHttpRequest will only send the file path as a string.
				case undefined:
					// stub case for fieldset element which returns undefined.
				case 'reset':
					// stub case for input type reset button.
				case 'button':
					// stub case for input type button elements.
				case 'submit':
				break;
				default:
					sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
			}
		}
	}

	sFormData = sFormData.substr(0, sFormData.length - 1);

	return sFormData;
}

function getValues( params, name )
{
	var values = "";
	var nvpair = params.split( "&" );
	var nv;
	for( var i=0; i<nvpair.length; i++ )
	{
		nv = nvpair[i].split( "=" );

		if( nv.length > 1 )
		{
			if( nv[0] == name )
				return nv[1];
		}
	}
	return;
}

function showDiv(obj1, obj, e){
	var wk = document.getElementById(obj);
	var wk1 = document.getElementById(obj1);
	
	var ie4=document.all
	var ns6=document.getElementById&&!document.all
 
	y = getAbsoluteTop(wk1) - 70;
	x = e.clientX + document.body.scrollLeft  - parseInt(wk1.offsetWidth/2) + 100;

	var edgeoffset=0;

	var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset

	var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18;

	wk.contentmeasure=560;

	if (windowedge-y < wk.contentmeasure){ //move menu up?
		edgeoffset=wk.contentmeasure-50;

		if ((y-topedge)<wk.contentmeasure) //up no good either? (position at top of viewable window then)
		{	
			edgeoffset=y-topedge - 50;
//			alert( y-topedge);
		}
	}

	wk.style.display = 'block';
	wk.style.left = x+"px";
	wk.style.top= y - edgeoffset+"px";
}

function hidDiv(obj){
	var sm = document.getElementById(obj);
	
	with(sm.style)
	{
		display = 'none';
	}
}

function getAbsoluteTop(oNode){
	var oCurrentNode=oNode;
	var iTop=0;
	while(oCurrentNode.tagName!="BODY"){
		iTop+=oCurrentNode.offsetTop;
		oCurrentNode=oCurrentNode.offsetParent;
	}
	return iTop;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}

function open_window(url, name, w, h)
{

	var win = null;
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	var settings  ='height='+h+',';
	settings +='width='+w+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='scrollbars=yes,';
	settings +='resizable=yes,toolbar=no,menubar=no,status=no, titlebar=no, location=no, ,directories=no';

//		var item_no = document.getElementById( "item_no" );
	var win = window.open(url, name, settings);
	
	if( parseInt( navigator.appVersion ) >= 4 )
		win.window.focus();
}

function open_window2(url, name, w, h)
{

	var win = null;
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	var settings  ='height='+h+',';
	settings +='width='+w+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='scrollbars=yes,';
	settings +='resizable=yes,toolbar=no,menubar=no,status=yes';

//		var item_no = document.getElementById( "item_no" );
	var win = window.open(url, name, settings);
	
	if( parseInt( navigator.appVersion ) >= 4 )
		win.window.focus();
}

//BSI old script 2009.04.14
function currencyDot(obj)
{
	//alert(event.keyCode); // 8:Backspace, 9:Tab, 46:Delete, 190: Dot,  96~105: Right KeyPad, 110:Right Dot, 17:Ctrl, 67:C, 86:V
	if (event.keyCode == 17 || event.keyCode == 67 || event.keyCode == 86 || event.keyCode == 46 || event.keyCode == 190 || event.keyCode == 110 || ((event.keyCode >= 8 && event.keyCode <= 9) || (event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105))) {
  	} else {
  		event.returnValue = false
  	}
}

function currency(obj)
{
	//alert(event.keyCode); // 8:Backspace, 9:Tab, 46:Delete, 96~105: Right KeyPad, 17:Ctrl, 67:C, 86:V
	if (event.keyCode == 17 || event.keyCode == 67 || event.keyCode == 86 || event.keyCode == 46 || ((event.keyCode >= 8 && event.keyCode <= 9) || (event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105))) {
	} else {
  		event.returnValue = false
  	}
}

function ZeroCheck(obj)
{
	if(obj.value == "")
		obj.value = 0;
}

function delay(gap){ /* gap is in millisecs */
	var then,now;
	then=new Date().getTime();
	now=then;
	while((now-then)<gap)
	{
		now=new Date().getTime();
	}
}