function GotoUrl( url, width, height ) {
    if ( (width!=null) || (height!=null) ) {
        OpenWindowed( url, width, height );
        return false;
    }
    document.location = url;
    return false;
}

function OpenWindowed( url, width, height ) {
    if ( width=='' || width==null ) width = 0;
    if ( height=='' || height==null ) height = 0;
    if (width==0) width = 600;
    if (height==0) height = 450;
    var attributes = 'height='+height+',width='+width+',status=no,toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes';
	window.open( url, 'newwindow', attributes );
    return false;
}

function MessageBox( message, url ) {
    alert(message); 
    if (url!='') document.location=url;
}

function MessageBoxConfirm( message, yesurl, nourl ) {
    var yes = confirm(message); 
    if (yes) {
        if (yesurl!='') document.location=yesurl;
    } else {
        if (nourl!='') document.location=nourl;
    }
}

var validators = new Array();

function ValidateSubmit(form) {
	for(var i=0; i<validators.length;i++) if (!validators[i].validate()) return false;
	return true;
}

function numberInput( elm ) {
    val = elm.value;
    val = parseInt( val );
    if (isNaN( val )) val = 0;
    val = Math.abs( val );
    if (elm.value!=val.toString()) elm.value=val;
}

function gotoBookmark( bm ) {
	location.hash = bm;
}

function OnLoad() {
  // NetScape fix
  if (!document.all) {
  	NSFix();
	window.onresize=NSReload;
  }
}

function NSFix() {
	x = document.getElementById('MasterTable');
	y = document.getElementById('MasterContent');

	if (parseInt(navigator.appVersion)==5) {
		// NS6
		x.style.height=window.innerHeight-115;
	}
	if (parseInt(navigator.appVersion)==6) {
		// NS7
		x.style.height="100%";
		y.style.height=window.innerHeight;
	}
}

function NSReload() {
	location.reload();
}


function PrintPage( id ) {
	window.open('../../print/en/'+id+'.aspx', '_blank','width=570,location=no,scrollbars=yes,menubar=no,resizable=yes,menubar=yes');
}

function OpenPopup( id, w, h ) {
	window.open('page.aspx?id='+id ,'_blank' ,"height="+h+",width="+w+",status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");
}

function OpenWindow(sURL,w,h) {
	window.open(sURL,null,"height="+h+",width="+w+",status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");
}

function open_window( url, width, height, resizeable, scrollbars ) {
	window.open(url,'','resizable='+resizeable+',scrollbars='+scrollbars+', menubar=0,width='+width+',height='+height);
}

function open_popup( popupname ) {
	switch (popupname) {
		case 'videos': open_window('popups/videos/videos.htm',320,110, 0, 0);
			break;
		case 'catalogue': open_window('popups/catalogue request/step1.asp',640,600, 1, 1);
			break;
		case 'cryosurvey': open_window('popups/cryosurvey/index.htm',262,133, 1, 1);
			break;
		case 'special': open_window('popups/special/index.htm',500,500, 1, 1);
			break;
	}
}

function OpenPopupWindow( url, w, h ) {
	window.open( url, "_blank" ,"height="+h+",width="+w+",status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no");
}

function FlashActivate() {
    if(document.all) {
        var objs=document.getElementsByTagName('object');
        for(var i=0;i<objs.length;i++) {
            objs[i].outerHTML=objs[i].outerHTML;
        }
    }
}
