
//DIV Popup logic
function isString(a){
	 return typeof a == 'string';
 }
function isObject(a) {
	return (a && typeof a == 'object') || isFunction(a);
}
function isArray(a) {
    return isObject(a) && a.constructor == Array;
}
function isUndefined(a) {
    return typeof a == 'undefined';
} 

//Display div popup window
function Div_Popup_Display(oInnerPopup, bDisplay, iWidth, iHeight, iLeft, itop, bIsScrollable){
	
	var oPopup = document.getElementById('divPopup');
	var oPopupContent = document.getElementById('divPopupContent');
	
	if (bDisplay ==-1) bDisplay = ! Div_IsVisible(oPopup);	
	if (isString(oInnerPopup)) {oInnerPopup = document.getElementById(oInnerPopup);}	
	if ((isObject(oPopup)) & (isObject(oInnerPopup)) & (isObject(oPopupContent))){
		//Display
		if(bDisplay){
			oPopup.style.width = iWidth;
			oPopup.style.height = iHeight;			
			oPopup.style.left = iLeft;
			oPopup.style.top = itop;
			if (bIsScrollable){
				//oPopupContent.style.width = iWidth - 16;
				//oPopupContent.style.Height = iHeight - 18;
			}
			//Append child
			oPopupContent.appendChild(oInnerPopup);
			oPopup.style.display = '';
			oInnerPopup.style.display = '';
		}else{
			oPopup.style.display = 'none';
			oInnerPopup.style.display = 'none';
		}
	}		
}

function Div_IsVisible(oDiv){
	if (isString(oDiv)) {oDiv = document.getElementById(oDiv);}	
	var bDisplay = !(oDiv.style.display == 'none');
	return bDisplay;
}

//Get content from DIV
function Div_GetContent(oDiv){
	if (isString(oDiv)) {oDiv = document.getElementById(oDiv);}
	if (isObject(oDiv)){ 
		return oDiv.innerHTML;
		return true;
	}else{ return false;}
}
//Set content to DIV
function Div_SetContent(oDiv, sContent){
	if (isString(oDiv)) {oDiv = document.getElementById(oDiv);}
	if (isObject(oDiv)){ 
		oDiv.innerHTML = sContent;
		return true;
	}else{ return false;}
}
//Loading image
function Div_Loading(oDiv, bLoading){
	var sLoadingImg = "<img src=\"images/loading.gif\" alt=\"\">";
	if (isString(oDiv)) {oDiv = document.getElementById(oDiv);}	
	if(isObject(oDiv)){
		if(bLoading){
			oDiv.innerHTML = sLoadingImg;
		}else{
			oDiv.innerHTML = "";
		}
	}	
}

function Div_Popup_Hide_Comboboxes(bHide, oForm, arComboNames){
	if (! isArray(arComboNames)|(! isObject(oForm))){return false;}		
	if (bHide ==-1)  bHide = Div_IsVisible('divPopup');
	var oElement = null;
	for(var i=0;i<arComboNames.length;i++){
		oElement = oForm.elements[arComboNames[i]];
		if (isObject(oElement)){
			if(bHide){
				oElement.style.visibility="hidden";
			}else{
				oElement.style.visibility = "visible";
			}
				
		}
	}
}

function RandomNumber(){
	return Math.random(); 
}

