
var isNav4, isIE4, isNav6 = false;
var range = "";
var styleObj = "";

if (navigator.appVersion.charAt(0) >= 4) {
	if (navigator.appName == "Netscape") {
		if (navigator.appVersion.charAt(0) >= 5) {
			isNav6 = true;
		}
		else {
			isNav4 = true;
		}
	}
	else {
		isIE4 = true;
		range = "all.";
		styleObj = ".style";
	}
}

function getObject(obj) {
	var theObj;
	if (typeof obj == "string") {
		if (isNav6) {
			theObj = document.getElementById(obj);
			if (theObj != null) theObj = theObj.style;
		}
		else {
			theObj = eval("document." + range + obj);
			if (theObj != null) theObj = eval("theObj" + styleObj);
		}
	}
	else {
		theObj = obj;
	}
	return theObj;
}

function show () {
	var theObj;
	for (var i = 0; i < show.arguments.length; i++) {
		theObj = getObject(show.arguments[i]);
		if (theObj != null) {
			theObj.display = "block";
			theObj.visibility = "visible";
		}
	}
}

function hide () {
	var theObj;
	for (var i = 0; i < hide.arguments.length; i++) {
		theObj = getObject(hide.arguments[i]);
		if (theObj != null) {
			theObj.display = "none";
			theObj.visibility = "hidden";
		}
	}
}

function ValidateZip(value)
{
	var re = /^\d{5}$/;
	return re.test(value);
}

function offerBoxActivate(offerBox, offerCount) 
{
	for (var i = 1; i <= offerCount; i++)
	{
		var boxID = "" + i;
		var boxName = "offerBox" + boxID;
		if (offerBox == boxID)
		{
			show(boxName);
		}
		else
		{
			hide(boxName);
		}
	}
}

function changeBtn(offerBtn, offerBtnCount, baseSkinPath) {
	for (var i = 1; i <= offerBtnCount; i++)
	{
		var btnID = "" + i;
		var btnName = "offerBtn" + btnID;
		if (offerBtn == btnID)
		{
			newImage = "url(" + baseSkinPath + "/images/offer_nav_on.gif)";
			document.getElementById(btnName).style.backgroundImage = newImage;
			document.getElementById(btnName).style.color = '#000000';
		}
		else
		{
			newImage = "url(" + baseSkinPath + "/images/offer_nav_off.gif)";
			document.getElementById(btnName).style.backgroundImage = newImage;
			document.getElementById(btnName).style.color = '#FFFFFF';
		}
	}
}

function launchWindow(strURL, strName, intWidth, intHeight, strProperties) 
{
	createWindow(strURL, strName, intWidth, intHeight, strProperties);
}

function createWindow(strURL, strName, intWidth, intHeight, strProperties)
{
	var mywin;
	var intVersion;
	var dummyDate = new Date(); 
/*
	if (strURL != "") 
	{
		if (strURL.indexOf("?") != -1) { 
			strURL = strURL + "&rnd="
		} else {
			strURL = strURL + "?rnd="
		}
			
		strURL = strURL + dummyDate.getTime();
	}
*/	
	if (strProperties == "") {
		strProperties = "scrollbars=yes,resizable=yes,menubar=no,location=no,directories=no,toolbar=no";
	}
	
	strProperties = "status=yes,height=" + intHeight + ",width=" + intWidth + "," + strProperties;
	
	strName = strName.toLowerCase();
	
	mywin = window.open(strURL, strName, strProperties);

	return mywin;
}

function setStyleByName(n, p, v)
{
	var elements = document.getElementsByName(n);
	for(var i = 0; i < elements.length; i++)
	{
		elements.item(i).style.backgroundColor = v;
	}
}

var cclass = "odd";
function setBgColor(box, oddColor, evenColor)
{
	var color;
	if (cclass == "odd")
	{
		if (oddColor == null)
		{
			oddColor = "#EDEEEF";
		}
		
		cclass = "even";
		setStyleByName(box, "backgroundColor", oddColor);
	}
	else
	{
		if (evenColor == null)
		{
			evenColor = "#F8F8F9";
		}

		cclass = "odd";
		setStyleByName(box, "backgroundColor", evenColor);
	}
}

function ReplaceTokenInText( emailObject, emailText, tokenText, token )
{
	var s = document.forms['Form1'].elements[emailText].value;
	var s2 = s.replace( token, tokenText );
	document.forms['Form1'].elements[emailObject].value = s2;
}

var redirectUrl = "";
var tFunc = "";
function RedirectOnTimeout(timeout)
{
	tFunc = setTimeout("PageRedirect()", timeout);
} 

function PageRedirect()
{
	document.location = redirectUrl;
}

function trackSpotlight(src, type, cat) {
	var click1 = new Image();
	var axel = Math.random() + "";
	var ord = axel * 1000000000000000000;
	//click1.src = 'http://ad.doubleclick.net/activity;src=123456;type=test123;cat=test456;ord=' + ord + '?';
	click1.src = 'http://ad.doubleclick.net/activity;src=' + src + ';type=' + type + ';cat=' + cat + ';ord=' + ord + '?';
}

function PrintSelect(sName, sDisplay)
{
  var tag = document.getElementById(sName);
  var tagDisplay = document.getElementById(sDisplay);
  var winPrint = window.open(' ', 'popPrint', 'scrollbars=no,resizable=no,menubar=no,location=no,directories=no,toolbar=no,status=yes,height=365,width=575');
  tagDisplay.style.display = '';
  //winPrint.document.write( tag.innerHTML + '<script> self.blur(); self.moveTo(10000,10000); self.resizeTo(1,1); self.blur(); if (navigator.appName=="Netscape") {if(window.opener){window.opener.focus();}} </script>');
  winPrint.document.write( ' <button type="button" OnClick="javascript:print();">Print</button>' + tag.innerHTML );
  tagDisplay.style.display = 'none';
  winPrint.document.close();
  winPrint.moveTo((screen.width-575)/2,(screen.height-365)/2);
//  winPrint.print( );
//  winPrint.close();
} 

function shownews(id)
{
    thumb = document.getElementById("newsletter");
    thumb.style.left = moveXbySlicePos(50, document.getElementById("mastheadcontent")) + 'px';
    thumb.style.top = moveYbySlicePos(42, document.getElementById("mastheadcontent")) + 'px';
	thumb.style.zIndex = 100;
    thumb.style.display = '';
    
    niframe = document.getElementById("newsiframe");
    niframe.src = "http://lmanewsletters.twcl.com.ar/newslettercms.aspx?lm=" + id;
	
    thumb2 = document.getElementById('DivShim');
    thumb2.style.width = thumb.offsetWidth;
    thumb2.style.height = thumb.offsetHeight;
    thumb2.style.top = thumb.style.top;
    thumb2.style.left = thumb.style.left;
    thumb2.style.zIndex = thumb.style.zIndex - 1;
    thumb2.style.display = "block";  
    
    /*
    s_linkTrackVars = 'prop1,events,eVar1';
    s_linkTrackEvents = 'event3';
    s_events = 'event3';
    s_eVar1 = 'Cadillac VIP Newsletter';
    var s_prop1= 'Cadillac VIP Newsletter';
    s_linkType= 'e';
    s_linkName = 'Cadillac VIP Newsletter';
    s_lnk=s_co(this);
    s_gs(s_lmgrs);
    */
}

function hiddennews()
{
    document.getElementById("newsletter").style.display = 'none';
    document.getElementById('DivShim').style.display = 'none';
}
