
function conditionalLoad(question, url) {
	if(confirm(question)) {
		window.open(url, "_self");
	}
}

function cogpop_scrollable(width, height, name, sourceurl){

        // actually open the window	and ensure we know what window opened us
        popupWin = window.open(sourceurl, name,'resizable=yes,titlebar=no,scrollbars=yes,width=' + width + ',height=' + height);
        if( popupWin.opener == null) popupWin.opener=self;
}

function cogpop(width, height, name, sourceurl){

        // actually open the window	and ensure we know what window opened us
        popupWin = window.open(sourceurl, name,'resizable=yes,titlebar=no,scrollbars=no,width=' + width + ',height=' + height);
        if( popupWin.opener == null) popupWin.opener=self;
}


function showMe(showmeId, hidemeId){
 var showme;
 var hideme;
 if(showmeId != null) {
   showme = document.getElementById(showmeId);
 }
 if(hidemeId != null) {
   hideme = document.getElementById(hidemeId);
 }
 if(document.all){// IE
   if(hideme !=null ){
     hideme.style.display = 'none';
   }
   if(showme != null){
    showme.style.display = 'inline';
   }
 } else if (navigator.userAgent.indexOf("Safari") > -1) {
   if(hideme != null){
     hideme.style.visibility = 'collapse';
     hideme.style.display = 'none';
   }
   if(showme != null){
     showme.style.display='table-row';
     showme.style.visibility = 'visible';
   }
 }else{// other
   if(hideme !=null ){
     hideme.style.display = 'none';
   }
   if(showme != null){
     showme.style.display = 'inline';
   }
 }
}

function show(id) {
    setDisplay(id, 'inline', 'table-row', 'visible', 'inline');
}

function hide(id) {
    setDisplay(id, 'none', 'collapse', 'none', 'none');
}

function setDisplay(
        id, ieDisplay, safariVisibility, safariDisplay, otherDisplay) {
    var element;
    
    if (id == null) {
        return;
    }
    
    element = document.getElementById(id);
    
    if (element == null) {
        return;
    }
    
    if (document.all) { // IE
        element.style.display = ieDisplay;
    } else if (navigator.userAgent.indexOf("Safari") > -1) {
        element.style.visibility = safariVisibility;
        element.style.display = safariDisplay;
    } else { // other
        element.style.display = otherDisplay;
    }
}

function toggleDisplay(id) {
    var element;
    
    var ieDisplayOn = 'inline';
    var ieDisplayOff = 'none';
    
    var safariVisibilityOn = 'table-row';
    var safariVisibilityOff = 'table-row';
    var safariDisplayOn = 'block';
    var safariDisplayOff = 'none';
    
    var otherDisplayOn = 'inline';
    var otherDisplayOff = 'none';
    
    if (id == null) {
        return;
    }
    
    element = document.getElementById(id);
    
    if (element == null) {
        return;
    }
    
    if (document.all) { // IE
        if(element.style.display == ieDisplayOn) {
	        element.style.display = ieDisplayOff;
	    } else {
	        element.style.display = ieDisplayOn;
	    }
    } else if (navigator.userAgent.indexOf("Safari") > -1) {
        if(element.style.display == safariDisplayOn) {
	        element.style.display = safariDisplayOff;
	        element.style.visibility = safariVisibilityOff;
	    } else {
	        element.style.display = safariDisplayOn;
	        element.style.visibility = safariVisibilityOn;
	    }
    } else { // other
        if(element.style.display == otherDisplayOn) {
	        element.style.display = otherDisplayOff;
	    } else {
	        element.style.display = otherDisplayOn;
	    }
    }
}

// AJAX
function getXmlHttp(){
	var xmlHttp = null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	} catch (e) {
	}
	if(xmlHttp == null) {
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		}
	}
	if(xmlHttp == null) {
		try {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {
		}    
	}
	return xmlHttp;
}

