/* popup */

var sUserAgent = navigator.userAgent.toLowerCase();
var isIE = document.all?true:false;
var isNS4 = document.layers?true:false;
var isOp = (sUserAgent.indexOf('opera')!=-1)?true:false;
var isMoz = (sUserAgent.indexOf('mozilla/5')!=-1 && sUserAgent.indexOf('opera')==-1 && sUserAgent.indexOf('msie')==-1)?true:false;

// ****************************************************************
// Example use:
//   <a href="/foo.htm" onclick="return pop(this,'survey');" title="Survey opens a new window.">Take our survey!</a>
//   <a href="/foo.htm" onclick="return pop(this,'','width=200,height=200');" title="Opens a new window.">Foo</a>
//   <a href="/foo.htm" onclick="return pop(this);" title="Opens a new window.">Foo</a>
// ****************************************************************
function pop(oAnchor,sWindow,sProps){
	var sUrl = '';
	if(oAnchor.getAttribute) sUrl = oAnchor.getAttribute('href');
	if(sUrl=='' && isIE) sUrl = window.event.srcElement.getAttribute('href');
	if(sUrl=='') sUrl = oAnchor.href;
	var sWindowName = sWindow?sWindow:'_blank';
	if(!sProps) sProps = 'width=640,height=480,scrollbars,resizable,toolbar,status,menubar,location';
	if(sUrl) var oPopup = window.open(sUrl,sWindowName,sProps);
	if(oPopup && !isOp) oPopup.focus();
	return (oPopup)?false:true;
}
function redirect(sTarget,oAnchor,bCloseSelf){
	var sUrl = '';
	if(oAnchor.getAttribute) sUrl = oAnchor.getAttribute('href');
	if(sUrl=='' && isIE) sUrl = window.event.srcElement.getAttribute('href');
	if(sUrl=='') sUrl = oAnchor.href;
	if(sTarget && sUrl) {
		eval(sTarget+".location='"+sUrl+"'");
		eval(sTarget+".focus()'");
	}
	if(bCloseSelf) self.close();
	return false; // false invalidates the real href attribute
}

/* toggle visibility of elements with a click */

function toggle(element) {
     element = document.getElementById(element);
     if (element.className == '') {
       element.className = 'collapse';
     } else {
       element.className = '';
     }
}

/* print screens */

function printWindow(){
   bV = parseInt(navigator.appVersion)
   if (bV >= 4) window.print()
}

/* click on logo to go back to orbit in main page and close popup */

function clickLogo() {
	if (window.opener) {
		window.close();
		window.opener.focus();
	} else {
		window.close();
		window.open('http://www.orbitdesignstudio.com','orbit');
	}
}

function setColor(c1, c2, myMenu, totalMenu){
	for(i=1; i<=totalMenu; i++){
		document.getElementById("m"+i).style.color = c2;
	}
	document.getElementById("m"+myMenu).style.color = c1;
}


/* Ajax rewrite on div*/
function ajaxHead(file){
	var ajaxRequest;	
	try{ajaxRequest = new XMLHttpRequest();
	} catch (e){
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				alert("Your browser broke!");
				return false;
			}
		}
	}
     return ajaxRequest;
}
function rewrite(divName,file){
   var ajaxRequest=ajaxHead(file);
   	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById(divName);
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	ajaxRequest.open("GET", file, true);
	ajaxRequest.send(null);
}

