// JavaScript Document
var commonspot_headerheight = 125;
var commonspot_footerheight = 110;

function detectHeight() {
        var wh = 0;
        if (typeof(window.innerHeight)=="number") {
                wh = window.innerHeight;
        }
        else {
                if (document.documentElement && document.documentElement.clientHeight) {
                        wh = document.documentElement.clientHeight;
                }
                else {
                        if (document.body && document.body.clientHeight) {
                                wh = document.body.clientHeight;
                        }
                }
        }
        return wh;

} 


function detectWidth() {
        var wh = 0;
        if (typeof(window.innerWidth)=="number") {
                wh = window.innerWidth;
        }
        else {
                if (document.documentElement && document.documentElement.clientWidth) {
                        wh = document.documentElement.clientWidth;
                }
                else {
                        if (document.body && document.body.clientWidth) {
                                wh = document.body.clientWidth;
                        }
                }
        }
        return wh;

} 


function setTabsHeight(){
	//return detectHeight() - commonspot_headerheight - commonspot_footerheight;
	return detectHeight() - commonspot_headerheight
}




function writejs(jsfile){
	
var script = document.createElement('script');
script.src = jsfile;
script.type = 'text/javascript';
script.defer = true;	
	
var head = document.getElementsByTagName('head').item(0);
head.appendChild(script);	

}	
	

function writecss(cssfile){
	
var css = document.createElement('link');
css.href = cssfile
css.type = 'text/css';
css.rel = 'stylesheet';	
	
var head = document.getElementsByTagName('head').item(0);
head.appendChild(css);	

}	
	

function ValidateAddTab(form){

		if(form.tab_name.value.length < 1){
			alert('Please enter a name for your tab.');
			return false;
		}
		
		
	
		for(var i = 0; i<form.tab_type.length;i++){
			if(form.tab_type[i].checked){
				var temp_type = form.tab_type[i].value;
			}
		}
		
		//alert(temp_type);
		
		if(temp_type == 'URL'){
			if(form.tab_url.value.length < 1){
				alert('Please Enter a valid url for this tab');	
				return false;
			}
		}
		
		
		
		$('fInsertTab').request(
			{	evalJS:'force',
				onComplete:function(){
					Ext.WindowMgr.getActive().close();
					if(temp_type == 'LAYOUT'){
						Ext.Msg.show({
								title: 'Tab Created',
								msg: 'You have created a new DASHBOARD tab. You can add items by clicking on the "ADD STUFF" button.',
								buttons: Ext.MessageBox.OK
									 });
						
					}
					
				if(temp_type == 'URL'){
						Ext.Msg.show({
								title: 'Tab Created',
								msg: 'You have created a new URL tab. Please note, the RSNA cannot be responsible for problems caused by this external website. Some sites do not allow their content to be allowed within tabs.',
								buttons: Ext.MessageBox.OK
									 });
						
					}					
					
				}
			});
		
		return false;
	}
	
	
	
function ValidateUpdateTab(form){

		if(form.tab_name.value.length < 1){
			alert('Please enter a name for your tab.');
			return false;
		}
		
}
	
	