﻿var isIE=window.external&&(navigator.platform=="Win32"||(window.ScriptEngine&&ScriptEngine().indexOf("InScript")+1));
var isFF=(navigator.userAgent.toLowerCase().indexOf("firefox")+1)?true:false;
var isOP=window.opera&&window.print;
var isNS=window.netscape&&!isOP;
var isSF=(navigator.userAgent.toLowerCase().indexOf("safari")+1)?true:false;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false;

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE);

// Set-up to use getMouseXY function onMouseMove
//document.onmousemove = getMouseXY;

// Main function to retrieve mouse x-y pos.s

function showpromo()
{
    var item = document.getElementById('promoactive');
    item.style.display = ""; 
    
    var item = document.getElementById('btClosePromo');
    item.style.display = ""; 
    
    for (i = 1; i < 6; i++)
    {
        try
        {
            var area = document.getElementById('tbDisplayArea' + i);
           
            area.style.fontWeight = "normal";
            area.style.color = "#888888";
        }
        catch(e)
        {
        
        }
    }
}

function hidepromo()
{
    var item = document.getElementById('promoactive');
    item.style.display = "none";
    
    var item = document.getElementById('tbTextArea');
    item.style.display = "none"; 
    
    var item = document.getElementById('btClosePromo');
    item.style.display = "none"; 
    
    //var copy = document.getElementById('btCopy');
    //copy.style.display = "none"; 
}

function showPromoOver(index)
{
    var area = document.getElementById('tbDisplayArea' + index);
           
    area.style.cursor = "hand";
    
    area.style.color = "#E45B00";
}

function showPromoOut(index)
{
    var area = document.getElementById('tbDisplayArea' + index);
    
    if(area.style.fontWeight == "normal")
    {
        area.style.color= "#888888";
    }
}

function ShowHide(id)
{
    e = document.getElementById(id);
    with(e.style) {
        if (visibility == 'hidden' || visibility == '') {
            display = '';
            visibility = 'visible';
        } else {
            display = 'none';
            visibility = 'hidden';
        }
    }
}

function escapeHtml(str)
{
    return str.replace(/>/g,"&gt;").replace(/</g,"&lt;");
}

function unescapeHtml(str)
{
    return str.replace(/&gt;/g,">").replace(/&lt;/g,"<");
}

function showPromoHtml(obj, sHtmlId)
{
    yPos = getObjYPos(obj);
    hId = document.getElementById(sHtmlId);
    if (hId != null) {
        divshow = document.getElementById("divShowHtml");
        if (divshow != null) {
            tashow = document.getElementById("taShowHtml");
            if (tashow != null) {
                str = unescapeHtml(hId.value);
                tashow.value = str;
                divshow.style.left = ((obj.ownerDocument.body.parentNode.clientWidth / 2) - (500 / 2)) + "px";
                divshow.style.top = ((obj.ownerDocument.body.parentNode.scrollTop) + (obj.ownerDocument.body.parentNode.clientHeight / 2) - (340 / 2)) + "px";
                if (divshow.style.left.indexOf("-") > -1) divshow.style.left = "0px";
                if (divshow.style.top.indexOf("-") > -1) divshow.style.top = "0px";
                divshow.style.visibility = "visible";
                divshow.style.display = "";
                tashow.focus();
                tashow.select();
            }
        }
    }
}

function getObjYPos(obj)
{
    var iReturnValue = 0;
    if( obj != null ) {
        iReturnValue += obj.offsetTop;
        obj = obj.offsetParent;
    }
    return iReturnValue;
}

function hideHtmlObj(id)
{
    obj = document.getElementById(id);
    if (obj != null) {
        with(obj.style) {
            visibility = "hidden";
            display = "none";
        }
    }
}

function CopyObjTextToClipboard(id)
{
    obj = document.getElementById(id);
    if (obj != null)
    {
        newHtml = unescapeHtml(obj.value);
        CopyToClipboard(newHtml);
    }
}

function CopyToClipboard(strToCopy)
{
	if(window.clipboardData || isNS)
	{
		if(isIE && !isFF)
		{
			if(!window.clipboardData.setData("Text",strToCopy))
			{
				alert("The HTML was not copied to clipboard.");
				return false;
			}
		}
		else
		{
			try {netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");}
			catch(e) {
			    alert("Your current browser security settings do not allow copying to the clipboard. The HTML was not copied to the clipboard.");
				return false;
			}
			var clip;
			try {clip=Components.classes["@mozilla.org/widget/clipboard;1"].createInstance(Components.interfaces.nsIClipboard);}
			catch(e) {return false;}
			if (!clip) return false;
			var trans;
			try {trans=Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);}
			catch(e) {return false;}
			if (!trans) return false;
			trans.addDataFlavor("text/unicode");
			var supportStr=Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
			supportStr.data=strToCopy;
			trans.setTransferData("text/unicode",supportStr,strToCopy.length*2);
			var clipId;
			try {clipId=Components.interfaces.nsIClipboard;}
			catch(e) {return false;}
			if (!clipId) return false;
			clip.setData(trans,null,clipId.kGlobalClipboard);
		}
	}
	else
	{
		//if(isOP)
		//	oc(f);
		//else
			alert("Your browser doesn't support copying to the clipboard. The HTML was not copied to the clipboard.");
		return false;
	}

	alert("The following HTML was successfully copied to clipboard:\n\n" + strToCopy);
	return false;
}

function showArea(index)
{
    for (i = 1; i < 6; i++)
    {
        try
        {
            var area = document.getElementById('tbDisplayArea' + i);
           
            if(index == i)
            { 
                area.style.fontWeight = "bold";
                area.style.color = "#E45B00";
            }
            else
            {
                area.style.fontWeight = "normal";
                area.style.color = "#888888";
            }
        }
        catch(e)
        {
        
        }
    }

    var area = document.getElementById('tbArea' + index);
    var textarea = document.getElementById('tbTextArea');
    
    //var copy = document.getElementById('btCopy');
    //copy.style.display = ""; 
           
    textarea.style.display = "";
    textarea.value = area.firstChild.nodeValue;
}

function menuOver(item)
{
    var color = "#105CB6";
    
    if(item.style.fontWeight == "normal")
    {
        item.style.color = color;
    }
    
    if(item.style.fontWeight == "")
    {
        item.style.color = color;
    }
}

function menuOut(item)
{
    var color = "#AAAAAA";
    
    if(item.style.fontWeight == "normal")
    {
        item.style.color = color;
    }
    
    if(item.style.fontWeight == "")
    {
        item.style.color = color;
    }
}

function changeColor(item, index)
{
    var color = "#105CB6";
    var colorOn = "#000000";
    
    for (i = 0; i < 10; i++)
    {
        try
        {
            var menu0 = document.getElementById('ctl00_cphMainContent_ctl0' + i + '_m0');
            menu0.style.fontWeight = "normal";
            menu0.style.color = color;
            menu0.style.textDecoration = "underline";
            
//            var menu1 = document.getElementById('ctl00_cphMainContent_ctl0' + i + '_m1');
//            menu1.style.fontWeight = "normal";
//            menu1.style.color = color;
//            menu1.style.textDecoration = "underline";

            var menu2 = document.getElementById('ctl00_cphMainContent_ctl0' + i + '_m2');
            menu2.style.fontWeight = "normal";
            menu2.style.color = color;
            menu2.style.textDecoration = "underline";
            
            var menu3 = document.getElementById('ctl00_cphMainContent_ctl0' + i + '_m3');
            
            if(menu3 != null)
            {
                menu3.style.fontWeight = "normal";
                menu3.style.color = color;
                menu3.style.textDecoration = "underline";
            }
            
            var menu4 = document.getElementById('ctl00_cphMainContent_ctl0' + i + '_m4');
            
            if(menu4 != null)
            {
                menu4.style.fontWeight = "normal";
                menu4.style.color = color;
                menu4.style.textDecoration = "underline";
            }
            
            var menu5 = document.getElementById('ctl00_cphMainContent_ctl0' + i + '_m5');
            
            if(menu5 != null)
            {
                menu5.style.fontWeight = "normal";
                menu5.style.color = color;
                menu5.style.textDecoration = "underline";
            }
            
            var menu7 = document.getElementById('ctl00_cphMainContent_ctl0' + i + '_m7');
            
            if(menu7 != null)
            {
                menu7.style.fontWeight = "normal";
                menu7.style.color = color;
                menu7.style.textDecoration = "underline";
            }
            
            var menu8 = document.getElementById('ctl00_cphMainContent_ctl0' + i + '_m8');
            menu8.style.fontWeight = "normal";
            menu8.style.color = color;
            menu8.style.textDecoration = "underline";
           
            item.style.fontWeight = "bold";
            item.style.color = colorOn;
            item.style.textDecoration = "none";
            
            var current2 = document.getElementById('ctl00_cphMainContent_ctl0' + i + '_mTmp');
            current2.value = index;
            
            var menu10 = document.getElementById('ctl00_cphMainContent_ctl0' + i + '_m10');
            
            if(index != 0 && index != 1)
            {
                menu10.style.display = "";
            }
            else
            {
                menu10.style.display = "none";
            }
            
            break;
        }
        catch(e)
        {
            
        }
    }
}

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + (document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
    tempY = event.clientY + (document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0;}
  if (tempY < 0){tempY = 0;}
  
  return true;
}

var isShowing = false;
var nCount = 0;

function countdown()
{
    nCount--;
    if((nCount > 0) && isShowing == false)
    {
        window.setTimeout("countdown()", 1000);
    }else
    {
        if(isShowing == false)
        {
            var div = document.getElementById("dvChildren");
            div.style.display = "none";
        }
    }
}

function showMenu(el)
{

    getMouseXY(this);
    var div = document.getElementById("dvChildren");
    
    div.style.display = "inline";
    div.style.left = tempX + 'px';
    div.style.top = tempY + 'px';
    isShowing = true;
    nCount = 5;
}

function hideMenu(el)
{
    window.setTimeout("countdown()", 1000);
    isShowing = false;
}

function stillShowing()
{
    isShowing = true;
    nCount = 5;
}

function endShowing()
{
    window.setTimeout("countdown()", 1000);
    isShowing = false;
}

function WriteWelcome()
{
    document.write("<span style=font-size:16pt>Welcome to myLot!</span><br /><span style=\"font-size:12pt\">myLot is a growing community of individuals from around the world who enjoy sharing information, meeting new people, and helping each other out. We want you to join our community! Experience the internet in a whole new way.</span><p class=\"nav3\"><a href=\"http://www.mylot.com/nr/register.aspx\">sign up, it's free!</a>&nbsp;&nbsp;<a href=\"http://www.mylot.com/o/whatismylot.aspx\">learn more about myLot</a></p>");
}