// JavaScript Document
var commonspot_headerheight = 50;
var commonspot_footerheight = 25;
var tabsHeight = 0;


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 - commonspot_footerheight;
}




function writejs(jsfile){
//alert('writejs');	
var hasScript = false;
                        
for(var i=0;i < document.getElementsByTagName('script').length;i++){
	if(document.getElementsByTagName('script')[i].src.split(jsfile).length >1){
		hasScript = true;
	}

}// end for


if(!hasScript){

try{
	

	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);

}catch(e){
	// inserting via DOM fails in Safari 2.0, so brute force approach
	document.write('<script type="text/javascript" src="' + jsfile +'">' + String.fromCharCode(60) + '/script' + String.fromCharCode(62) );
	
}							
}// end if		


}	
	

function writecss(cssfile){
	
	
//alert('writecss');
var hasCss = false;
                        
for(var i=0;i < document.getElementsByTagName('link').length;i++){
	if(document.getElementsByTagName('link')[i].href.split(cssfile).length >1){
		hasCss = true;
	}

}// end for


if(!hasCss){

try{
	

	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);

}catch(e){
	// inserting via DOM fails in Safari 2.0, so brute force approach
	document.write('<link rel="stylesheet" type="text/css" href="' + cssfile +'">' + String.fromCharCode(60) + '/link' + String.fromCharCode(62) );
	
}							
}// end if	





}	
	

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;
		}
		
}
	
	