
 
window.onresize = reDo; 

//Define global variables 
var timerID = null; 
var timerOn = false; 
var timecount = 400; 

// Change this to the time delay that you desire 
var what = null; 
var newbrowser = true; 
var check = false; 

var currentLayer=null;
var buffering=false;

function reDo() { 
window.location.reload(); 
} 
 
function init() {
if (document.layers) { 
layerRef="document.layers"; 
styleSwitch=""; 
what ="ns4"; 
} 
else if(document.all) { 
layerRef="document.all"; 
styleSwitch=".style"; 
what ="ie4"; 
} 
else if(document.getElementById) { 
layerRef="document.getElementByID"; 
styleSwitch=".style"; 
what="dom1"; 
} 
else { 
what="none"; 
newbrowser = false; 
} 
check = true; 

    // checks through entire page and looks for links that don't contain any of the Strings in the 
    // alertExceptions array; opens spanishAlert function when those links are clicked

    var alertExceptions = new Array("USES", "US/ES", "mailto", "javascript", "/AppConsole/");
    for(i = 0; i < document.links.length; i++) 
    {	
	var current_link = document.links[i].href;
	
	if (document.links[i].target == '_blank') 
        {
		document.links[i].target = '_self';
	}

	var found = false;

	if (document.links[i].name == 'spanishTab')
        {
	    found = true;
        } else {
	    for(j = 0; j < alertExceptions.length; j++) 
            {	
                var testval = current_link.indexOf(alertExceptions[j]);
                found = testval > -1;
                //alert('current_link=' + current_link + ', testing for ' + alertExceptions[j] + ', result= ' + testval + ', found=' + found);
                if (found) break;
	    }
        }
        // if link contained none of the strings given in the array then wrap the link in js fn
        if (!found) {
            if (current_link == 'http://offers.e-centives.com/siflo/?id=7a47270c-6a7b-477a-8a30-a6bbe8abf08c&b=5939') {
		    	document.links[i].href = current_link;
			} else {
				document.links[i].href = 'javascript:spanishAlert("' + current_link + '")';
			}
        }
    }
}

// pops an alert up warning that you're opening a window that isnt spanish
function spanishAlert(dest) {
 
  self.location.href='/app/Colgate/USES/SpanishAlert.cvsp?url='+dest+'';
 
 } 

// Toggles the layer visibility on 
function showLayer(layerName) {
	currentLayer=layerName;
	
	if(check) { 
		if (what =="none") { 
			return; 
		}else if (what == "dom1") { 
			if(document.getElementById(layerName)!=null)
				document.getElementById(layerName).style.visibility="visible"; 
		}else { 
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"'); 
		}//if/else
	}//if
}

// Toggles the layer visibility off 
function hideLayer(layerName) { 
	if(check) { 
		if (what =="none") { 
			return; 
		}else if (what == "dom1") { 
			if(document.getElementById(layerName)!=null)
				document.getElementById(layerName).style.visibility="hidden"; 
		}else { 
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"'); 
		}//if/else
	}//if
}

function hideAll() {
	oDivTags = document.body.getElementsByTagName("DIV");
	for(x=0;x<oDivTags.length;x++){
		if(oDivTags[x]!=null && oDivTags[x].id.substr(0,4)=="nav_")
			hideLayer(oDivTags[x].id);
	}//for
}

function hideAllExcept(layerName) { 
	oDivTags = document.body.getElementsByTagName("DIV");
	for(x=0;x<oDivTags.length;x++){
		if(oDivTags[x]!=null && oDivTags[x].id != layerName)
			hideLayer(oDivTags[x].id);
	}//for
}

function startTime() { 
if (timerOn == false) { 
timerID=setTimeout( "hideAll()" , timecount); 
timerOn = true; 
} 
}

function stopTime() { 
if (timerOn) { 
clearTimeout(timerID); 
timerID = null; 
timerOn = false; 
} 
}

function onLoad() { 
init(); 
} 

function land(ref, target){
	lowtarget=target.toLowerCase();
	
	if (lowtarget=="_self"){
		window.location=loc;
	}else if (lowtarget=="_top"){
		top.location=loc;
	}else if (lowtarget=="_blank") {
		window.open(loc);
	}else if (lowtarget=="_parent") {
		parent.location=loc;
	}else {
		parent.frames[target].location=loc;
	}//if/else
}

function jump(menu){
	ref=menu.choice.options[menu.choice.selectedIndex].value;
	splitc=ref.lastIndexOf("*");
	target="";
	if (splitc!=-1){
		loc=ref.substring(0,splitc);
		target=ref.substring(splitc+1,1000);
	}else {
		loc=ref; target="_self";
	}

	if (ref != "")
		land(loc,target);
}
