// Main Bear Stearns all scripts functions

var domainURL = '';
var domainGuide = 0;

// redirect and strip out protocals
protocalRemover = new String(location.href);
stripProtocals = [':80',':443'];

for (i = 0; i < stripProtocals.length; i++) {
	if (protocalRemover.indexOf(stripProtocals[i]) != -1) {
		protocalRemover = protocalRemover.replace(stripProtocals[i],"");
		location.replace(protocalRemover);
		break;
	}
}

function extractDomain() {
	// get the default domain to have absolute calls to all image, scripts, and css
	if (domainURL == '') {
		// never include the trailing / for the domainGuide
		domainGuide = 'http://ecommerce:9003';
		domainGuide = domainGuide.split('/');
		domainGuide = domainGuide.length-1;
		
		var sURL = new String(location.href);
		sURL = sURL.toLowerCase();
		
		//var stringSplice = sURL.indexOf('://') + 3;
		//sURL = sURL.slice(stringSplice); // remove all http:// | https:// text
		
		var urlLocArray = sURL.split('/');
		
		for (var i = 0; i < urlLocArray.length; i++) {
			domainURL += urlLocArray[i];
			if (i == domainGuide) {
				break;
			}
			
			domainURL += '/';
		}
		
		// set the default script location for the hiermenus
		HM_ScriptDir = domainURL + '/includes/scripts/hmenus/';
		HM_ImageDir = domainURL + '/includes/images/';

		domainGuide--; // domainGuide is used to find the root for all scripts to follow; remove the additional http:// slashes from the count
	}
}


function include_script(script_filename) {
	if (script_filename.indexOf('://') == -1) {
		script_filename = domainURL + script_filename;
	}
	
	document.write('<scr'+'ipt language="javascript" type="text/javascript" src="'+ script_filename +'"><\/scr'+'ipt>');
	return false;

}

function include_css(css_filename, mediaType) {
	if (mediaType == undefined) {
		var mediaType = "all";
	}
	//href="includes/css/bearstearns.css"
	
	document.write('<li'+'nk rel="stylesheet" type="text/css" media="' + mediaType + '" href="'+ domainURL + css_filename +'"/>');
	
	return false;
}

extractDomain();

//include_script("http://www.bearstearns.com/includes/scripts/mootools.js");
//include_script("http://www.bearstearns.com/includes/scripts/utilities.js");
//include_script("http://www.bearstearns.com/includes/scripts/hmenus/HM_Loader.js");
//include_script("http://www.bearstearns.com/includes/scripts/framework_standalone.js");
//include_script("http://www.bearstearns.com/includes/scripts/flash_filmstrip.js"); // comment out if no flash is used

include_script("/includes/scripts/mootools.js");
include_script("/includes/scripts/utilities.js");
include_script("/includes/scripts/framework_standalone.js");
include_script("/includes/scripts/flash_filmstrip.js"); // comment out if no flash is used

include_script("/includes/scripts/hmenus/HM_Loader.js");
include_script("/includes/scripts/footer.js");
include_script("/includes/scripts/lightbox.js");






function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}




function printListing(whichone) {
	
	
	obj = $('printdetail');
	orig = obj.innerHTML;
	
	
	
	
	
		obj.innerHTML =  obj.innerHTML + document.getElementById('x_'+whichone+'').innerHTML 
		if (window.ie) {
			obj.setStyle('display', 'block');
			$('bodycontainer').setStyle('display', 'none');
		}
		
		setActiveStyleSheet('printnone');
	
	//setTimer = setInterval(function() {
	//	clearInterval(setTimer);							
		window.print();							
	//}, 1000)
		if (window.ie) {
			obj.setStyle('display', 'none');
			$('bodycontainer').setStyle('display', 'block');
		}
		
	setActiveStyleSheet('printall')
	obj.innerHTML = orig
	
	}
	
	function sw(y,x){
t=document.getElementById(x).style
t.display=(y=='on')?'block':'none'

}

oldone = ""
function showHide(ele){
	
	if (document.getElementById(ele).style.display == 'none'){
		sw('on',ele)
		
		if(oldone != "") {
			sw('off',oldone)
			
		}
		
		oldone = ele
	}else{
		sw('off',ele)
		oldone = ""
	}
}

function loadLB() {
	loadLightBoxManually = false;
	initLightbox();
	document.getElementById('rightlinks').style.display = 'block';
}

function waitMove(){
setTimeout("nextPage()", 1800) }


function nextPage(whereto) {
	if(!whereto) {
		goto = data2Load
		
	} else {
		
		goto = whereto }

window.scrollTo(0,document.getElementById(goto).offsetTop-10);

}

function getheight(x){
t=document.getElementById(x)

window.resizeTo(t.width+4, t.height+4)

}


