// POP UPS
// --------------------------------------------------------------

function viewContact(url){window.open(url,'viewContact','scrollbars=1,width=250,height=300');}
function viewPop(url){window.open(url,'viewPop',"toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=350,top=10,left=10");}

window.onload = function(){
	toggleSearch('searchCustom__locationTypeBranch','branchdetail');
	toggleSearch('searchCustom__locationTypeAtm','atmdetail');
	if($('searchCustom__locationTypeBranch')){
		$('searchCustom__locationTypeBranch').onclick = function(){
			toggleSearch('searchCustom__locationTypeBranch','branchdetail');
		}
		$('searchCustom__locationTypeAtm').onclick = function(){
			toggleSearch('searchCustom__locationTypeAtm','atmdetail');
			$('WACHOVIA_and_WF').checked=(this.checked ? true : false);
		}
	}
}


// TOGGLE ADVANCED SEARCH
// --------------------------------------------------------------

function toggleSearch(parent,child){
	if($(parent).checked){
		$(child).style.display='block';
		$(child).getElementsByTagName('input')[0].focus();
	}else{
		$(child).style.display='none';
		var inputs=$(child).getElementsByTagName('input');
		for(var x=inputs.length-1; x>=0; x--){
			inputs[x].checked=false;
		}
	}
}

// GET ELEMENT BY ID SHORTCUT
// --------------------------------------------------------------

function $() {
	var result = document.getElementById(arguments[0]);
    if (result === undefined || result === null)
    {
        result = document.createElement('span');
    }
    
    return result;
}

/* Provided by Shawn Olson & http://www.shawnolson.net */
function changecss(theClass,element,value) {
 var cssRules;
 if (document.all) {
  cssRules = 'rules';
 }
 else if (document.getElementById) {
  cssRules = 'cssRules';
 }
 for (var S = 0; S < document.styleSheets.length; S++){
  for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
   if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
    document.styleSheets[S][cssRules][R].style[element] = value;
   }
  }
 }  
}

var toggled = new Array();
var showingAll = false;
function toggle(id)
{
	var e = document.getElementById(id);
	if(showingAll || e.style.display == 'block')
	{
	    e.style.display = 'none';
	    showingAll = false;
	}
	else
    {
	    e.style.display = 'block';
	    toggled.push(id)
    }
    
    return false;
}

function showAll()
{
    changecss('.togglable', 'display', 'inline');
    for (var i=0; i < toggled.length; i++)
    {
        document.getElementById(toggled[i]).style.display = '';
    }
    showingAll = true;
}

function hideAll()
{
    changecss('.togglable', 'display', 'none');
    for (var i=0; i < toggled.length; i++)
    {
        document.getElementById(toggled[i]).style.display = '';
    }
    showingAll = false;
}

function findLigeoPlaceholder(place, map) {
	place = document.getElementById(place);
	map = document.getElementById(map);
	if (LigeoVarUtils.isNotNullOrEmpty(typeof(place.offsetParent))) {
		for(posX=0, posY=0; place; place = place.offsetParent) {
			posX += place.offsetLeft;
			posY += place.offsetTop;
		}
	} else {
		posX = place.x;
		posY = place.y;
	}
	map.style.left = posX + "px";
	map.style.top = posY + "px";
}
