nn6 = (document.getElementById && !document.all) ? 1 : 0;
op7 = (document.all && !document.styleSheets) ? 1 : 0;
ie5 = (document.getElementById && !nn6 && !op7) ? 1 : 0;

//window.onerror = handleError;
//function handleError(msg, url, ln) {
//   return true;
//}

function getStyleObject(objectId, doc){
	if(doc == null){
		doc = document;
	}
	
	if(doc.getElementById(objectId)){
		return doc.getElementById(objectId).style;
	}

	return false;
}

function getObject(objectId, doc){
	if(doc == null){
		doc = document;
	}
	
	if(doc.getElementById(objectId)){
		return doc.getElementById(objectId);
	}

	return false;
}

function changeObjectDisplay(objectId, newVisibility) {
	var styleObject = getStyleObject(objectId);
	if(styleObject) {
		styleObject.display = newVisibility;
		return true;
	}
	else{
		return false;
	}
}

function findPosX(object){
	var curleft = 0;
	if(object.offsetParent){
		while(object.offsetParent){
			curleft += object.offsetLeft;
			object = object.offsetParent;
		}
	}
	else if(object.x) {
		curleft += object.x;
	}
		
	return curleft;
}

function findPosY(object){
	var curtop = 0;
	if(object.offsetParent){
		//curtop += object.offsetHeight;
		while(object.offsetParent){
			curtop += object.offsetTop;
			object = object.offsetParent;
		}
	}
	else if(object.y) {
		curtop += object.y;
		curtop += object.height;
	}
	
	return curtop;
}


function formFocus(objectID){
	if(objectID != ''){
		element = document.getElementById(objectID);
		if(element && !element.disabled && !element.readonly && element.style.display != 'none' && element.style.visibility != 'hidden'){
			element.focus();
		}
		else{
			formFocus('');
		}
	}
	else if(document.forms[0]){
		for(i = 0; i < document.forms[0].elements.length; i++){
			element = document.forms[0].elements[i];
			if(element.type == 'text' || element.type == 'textarea' || element.type == 'password'){
				if(!element.disabled && !element.readonly && element.style.display != 'none' && element.style.visibility != 'hidden'){
					element.focus();
				}
			}
		}
	}
}

function Trim(str){
   return str.replace(/^\s*|\s*$/g,"");
}

function showHelp(templateName, pageType) {
	window.open('Help/ShowHelp.aspx?TemplateName=' + templateName + '&PageType=' + pageType, 'SmallWebWizardHelp', 'toolbar=yes, directories=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=400, height=500, top=' + (screen.height - 500) / 2 + ', left=' + (screen.width - 400) / 2).focus();
}

function showImage(imageID) {
	window.open('BLOBs/ShowImage.aspx?ImageID=' + imageID, 'SmallWebWizardImage', 'scrollbars=no, resizable=no, status=no, toolbars=no, width=200, height=200').focus();
}

function IframeCover(controlID, iframeID, doc){
	if(doc == null){
		doc = document;
	}

	var iframe = getObject(iframeID, doc);
	if(iframe){
		SetTopLeft(iframe, findPosY(doc.getElementById(controlID)), findPosX(doc.getElementById(controlID)), doc, true);	//we must allow this go go above zero pixels since the stuff it covers might
		//iframe.style.top = iframe.style.top - doc.all[controlID].offsetHeight;
		iframe.style.width = doc.all[controlID].offsetWidth;
		iframe.style.height = doc.all[controlID].offsetHeight;
		iframe.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
		iframe.style.display = 'block';
	}
}

function SetTopLeft(control, absolutTop, absolutLeft, doc, allowBelowZero){
	if(doc == null){
		doc = document;
	}
	if(allowBelowZero == null){
		allowBelowZero = false;
	}
	
	if(control){
		if(control.offsetParent){
			control.style.top = absolutTop - findPosY(control.offsetParent);
			control.style.left = absolutLeft - findPosX(control.offsetParent);
		}
		else{
			control.style.top = absolutTop;
			control.style.left = absolutLeft;
		}
		
		if(!allowBelowZero){
			if(control.style.posTop < 0){
				control.style.top = 0;
			}
			if(control.style.posLeft < 0){
				control.style.left = 0;
			}
		}
	}
}

function IFrameCoverOLDONLYHEREFORKOLLAMOT(objectID){
	if(ie5){
		width=parent.document.all[objectID].offsetWidth;
		height=parent.document.all[objectID].offsetHeight;
		var iframe = getStyleObject('AnnouncementIF', parent.document);
		if(iframe) {
			iframe.top = findPosY(objectID);
			iframe.left = findPosX(parent.document.getElementById(objectID));
			iframe.width=width;
			iframe.height=height;
			iframe.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
			iframe.display = 'block';
		}
	}
}


function PopupWindow(url, name, width, height){
	windowbits = "width=" + width + "px, height=" + height + "px, center=yes, border=thin, help=no, status=no, locationbar=no, statusbar=no, locationbar=no, menubar=no, toolbar=no";
	remote = window.open(url, name, windowbits);
	remote.focus();
	remote.resizeTo(width, height);
}