//  ********** MATCH HEIGHT - matches hights of DIVS with "matchheight" class  ************

matchHeight=function(){ 
     var divs,contDivs,maxHeight,divHeight,d; 
     divs=document.getElementsByTagName('div'); 
     contDivs=[]; 
     maxHeight=0; 
     for(var i=0;i<divs.length;i++){ 
          if(/\bmatchheight\b/.test(divs[i].className)){ 
                d=divs[i]; 
                contDivs[contDivs.length]=d; 
                if(d.offsetHeight){ 
                     divHeight=d.offsetHeight; 
                } 
                else if(d.style.pixelHeight){ 
                     divHeight=d.style.pixelHeight; 
                } 
                maxHeight=Math.max(maxHeight,divHeight); 
          } 
     } 
     for(var i=0;i<contDivs.length;i++){ 
          contDivs[i].style.height=maxHeight+'px'; 
     } 
} 

window.onload=function(){ 
     if(document.getElementsByTagName){ 
          matchHeight(); 
     } 
} 

//  ********** Hide Show / View More / Less  ************

function viewSelect(selectedOption) {
  var option1Style = document.getElementById('view_more').style;
  var option2Style = document.getElementById('view_less').style;
  var option3Style = document.getElementById('view_more1').style;
  var option4Style = document.getElementById('view_less1').style;

  if (selectedOption == "option1") {
	  option1Style.display = option1Style.display = "block";
	  option2Style.display = option2Style.display = "none";
	}
  if (selectedOption == "option2") {
	  option1Style.display = option1Style.display = "none";
	  option2Style.display = option2Style.display = "block";
	}
  if (selectedOption == "option3") {
	  option3Style.display = option3Style.display = "block";
	  option4Style.display = option4Style.display = "none";
	}
  if (selectedOption == "option4") {
	  option3Style.display = option3Style.display = "none";
	  option4Style.display = option4Style.display = "block";
	}

}

//  ********** POPUp Windows  ************

var width = screen.width;
var height = screen.height;
var popUpWidth = 0;
var popUpHeight = 0;
var positionTop = 0;
var positionLeft = 0;

function openWindowNoChrome(pageURL,windowName,pWidth,pHeight,pResize,pScrollbars) {
  positionTop = ((height/2) - (pHeight/2));
  positionLeft = ((width/2) - (pWidth/2));
  popup=window.open(pageURL,windowName, config='width=' + pWidth + ',height=' + pHeight + ',left=' + positionLeft + ',top=' + positionTop + ',resizable=' + pResize + ',menubar=0,location=0,directories=0,toolbar=0,scrollbars=' + pScrollbars + ',status=0');
	popup.focus();
}

//  ********** HOME PAGE MODAL WINDOW ********************
function OpenModalWindow()
{
	OnWindowResize();
	
	if (window.attachEvent)
		window.attachEvent('onresize', OnWindowResize);
	else if (window.addEventListener)
		window.addEventListener('resize', OnWindowResize, false);
	else
		window.onresize = OnWindowResize;
	
	if (document.all)
		document.documentElement.onscroll = OnWindowResize;

	$('modalBackground').style.width = GetWindowWidth();
	$('modalBackground').style.height = GetWindowHeight();
	$('modalBackground').style.display = 'block';
	
	$('modalWindow').style.visibility = 'visible';
	if (window.XMLHttpRequest == null)
	{
		var type = $('hideType');
		
		if (type)
			$('modalIframe').style.display = 'block';
	}

}

function OnWindowResize()
{
	var left = window.XMLHttpRequest == null ? document.documentElement.scrollLeft : 0;
	var top = window.XMLHttpRequest == null ? document.documentElement.scrollTop : 0;
	var div = $('modalWindow');
	
	div.style.left = Math.max((left + (GetWindowWidth() - div.offsetWidth) / 2), 0) + 'px';
	div.style.top = Math.max((top + (GetWindowHeight() - div.offsetHeight) / 2), 0) + 'px';
}

function CloseModalWindow()
{
	$('modalWindow').style.visibility = 'hidden';
	$('modalBackground').style.display= 'none';
	
	if (document.all)
	{
		var type = $('hideType');
		
		if (type)
			$('modalIframe').style.display = 'none';
	}
	
	if (window.detachEvent)
		window.detachEvent('onresize', OnWindowResize);
	else if (window.removeEventListener)
		window.removeEventListener('resize', OnWindowResize, false);
	else
		window.onresize = null;
}

function GetWindowWidth()
{
	var width =
		document.documentElement && document.documentElement.clientWidth ||
		document.body && document.body.clientWidth ||
		document.body && document.body.parentNode && document.body.parentNode.clientWidth ||
		0;
		
	return width;
}

function GetWindowHeight()
{
    var height =
		document.documentElement && document.documentElement.clientHeight ||
		document.body && document.body.clientHeight ||
  		document.body && document.body.parentNode && document.body.parentNode.clientHeight ||
  		0;
  		
  	return height;
}

function $(id)
{
	return document.getElementById(id);
}

//  ********** LOADING FLASH FUNCTIONS ********************

function startCustomers() {
 	var so = new SWFObject("swf/SBS_wizard.swf", "flash_wizard", "980", "420", "7");
		so.addParam("quality", "high");
		so.addParam("wmode", "transparent");
		so.addVariable("cstracker", "customers");
		so.write("modalWindow");
}
function startCompany() {
 	var so = new SWFObject("swf/SBS_wizard.swf", "flash_wizard", "980", "420", "7");
		so.addParam("quality", "high");
		so.addParam("wmode", "transparent");
		so.addVariable("cstracker", "company");
		so.write("modalWindow");
}
function startCompetitors() {
 	var so = new SWFObject("swf/SBS_wizard.swf", "flash_wizard", "980", "420", "7");
		so.addParam("quality", "high");
		so.addParam("wmode", "transparent");
		so.addVariable("cstracker", "competitors");
		so.write("modalWindow");
}
function startPartners() {
 	var so = new SWFObject("swf/SBS_wizard.swf", "flash_wizard", "980", "420", "7");
		so.addParam("quality", "high");
		so.addParam("wmode", "transparent");
		so.addVariable("cstracker", "partners");
		so.write("modalWindow");
}
function startBanks() {
 	var so = new SWFObject("swf/SBS_wizard.swf", "flash_wizard", "980", "420", "7");
		so.addParam("quality", "high");
		so.addParam("wmode", "transparent");
		so.addVariable("cstracker", "banks");
		so.write("modalWindow");
}
function startHome() {
 	var so = new SWFObject("swf/SBS_wizard.swf", "flash_wizard", "980", "420", "7");
		so.addParam("quality", "high");
		so.addParam("wmode", "transparent");
		so.addVariable("cstracker", "home");
		so.write("modalWindow");
}

// ************ Changing Tabs ************* //
var lastSelectedTab = "";
var selectedTab = "";
// changed this funtion for EPLTFM-8885,Release 7 by Rajesh Masna on 05-04-09
function changeTabs(whichTab,imagePath) {
	if (selectedTab != "") { lastSelectedTab = selectedTab; }
	selectedTab = whichTab;
	activeImagePath = imagePath+"/images/smbImages/smbdnb/tab_bg.jpg";
	inactiveImagePath = imagePath+"/images/smbImages/smbdnb/tab_arrow.gif";


	if (lastSelectedTab != "") {
	  document.getElementById('tab_copy_' + lastSelectedTab).style.display = "none";
	  document.getElementById(lastSelectedTab).style.backgroundImage = "url('"+inactiveImagePath+" ')";
	  
	}		
	document.getElementById('tab_copy_' + selectedTab).style.display = "inline";
	document.getElementById(selectedTab).style.backgroundImage = "url('"+activeImagePath+"')";
}



// *********** Hide Show ************** //
function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "block";
}

function trim(stringToTrim) {
return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
return stringToTrim.replace(/\s+$/,"");
}
