function findDOM(objectID)
{ var returnObject = null;
  try
  {
    if(document.getElementById)
    { returnObject = (document.getElementById(objectID));
    }
    else if(document.all)
    { returnObject = (document.all[objectID]);
    }
    else if(document.layers)
    { returnObject = (document.layers[objectID]);
    }

    return returnObject;
  }
  catch(e){alert("findDOM() has problem : "+e);}
}

function findDOMsByTag(tagName)
{
    tagName = tagName.toLowerCase();
    return document.getElementsByTagName(tagName);
}
function gotoBlocNewWindow(a) {
    return gotoBlocNewWindow(a, "900", "600");
}
function gotoBlocNewWindow(a,w,h) {
    var blocwin=window.open(a, "bloc", "width="+w+",height="+h+",toolbar=1,resizable=1,scrollbars=1");
    blocwin.focus(); 
    returnValue = false;
    return false;
}
function init() {
    var aS = findDOMsByTag('a');
    var leng = aS.length;
    var cur = (document.location + '').toLowerCase();
    var ind = cur.indexOf("?");
    if (ind > 0) {
        cur = cur.substr(0, ind);
    }
    for (var i = 0; i < leng; i++) {
        if (aS[i].href.toLowerCase() == cur) {
            aS[i].className = 'current';
        }
        if (aS[i].href.endsWith('/') && aS[i].href.startsWith('/')) {
            aS[i].href += 'index.aspx';
        }
    }
}
function init_long() {
    var aS = findDOMsByTag('a');
    var leng = aS.length;
    var cur = (document.location + '').toLowerCase();   
    for (var i = 0; i < leng; i++)
        if (aS[i].href.toLowerCase() == cur) {
        aS[i].className = 'current';
    }
}
function openManage(){
        var ie = navigator.appName == "Microsoft Internet Explorer";
        if(ie)
        {   if(this.top==this) {   
               
            var manage=window.open('/manage/pages2/extendPages/Pages/ultimate/Index.aspx','manage','fullscreen=1,channelmode=1,location=1,status=0,resizable=1,menu=0,menubar=0,toolbar=1,scrollbars=1');
                manage.focus();
            }
            else
            {   alert('You are already in Content Management System!');
            }
        }
        else
        {   alert('Only support Internet Explorer 7.0!');
        }
        void(0);
    }
function highlight(id)
{
    var link=document.getElementById(id);
    if(link)
    {
        link.style.color="red";
        link.style.fontSize="large";
    }
}
function dehighlight(id)
{
   var link=document.getElementById(id);
    if(link)
    {
        link.style.color="";
        link.style.fontSize="";
    }
}


function search_Close() {
    if (mailTrack) {
        mailTrack.close();
        mailTrack = null;
    }
    else {
        var mailTrackPanel = document.getElementById('MailTrackingResultPanel');
        mailTrackPanel.style['display'] = "none";
    }
}

var mailTrack;


function search_herc(box) {
    box = document.getElementById(box);
    if (box.value) {
        mailTrack = window.open("http://www.hercwatch.com/en-us/MailTracking/?track=" + box.value,
        "mailTrack",
        "width=700,height=380,resizable=1,scrollable=1");
        mailTrack.focus();
    }
    else {
        alert('Empty tracking number is not valid!');
    }

    returnValue = false;
    return false;
}

function search(box)
{   box = document.getElementById(box);
    if(box.value) {
        try {
            var mailTrack = document.getElementById('MailTrackingResult');
//            alert(mailTrack.src);
            mailTrack.src = "http://www.hercwatch.com/en-us/MailTracking/?track=" + box.value;
            var mailTrackPanel = document.getElementById('MailTrackingResultPanel');
            mailTrackPanel.style['display'] = "block";
            /*
            mailTrack = window.open("http://www.hercwatch.com/en-us/MailTracking/?track=" + box.value,
            "mailTrack",
            "width=580,height=280,resizable=1,scrollable=1");
            mailTrack.focus();    
            */
        } catch (e) {alert(e.message);}
     }
     else
     {
        alert('Empty tracking number is not valid!');
    }
   
    returnValue=false;
    return false;
}

function search_(keystroke, box) {
   var keyCode = (document.layers) ? keyStroke.which : event.keyCode;
   if (keyCode == 13) {
       search(box);
   }
}


function master(href)
{
    window.open('http://www.blocecatalog.com','','width=500,height=400,resizable=1');
    if(Event)
        preventDefault(Event);
    else
        returnValue=false;
    return false;
}

//<!--
var pop;
function Checkout(app)
{   if(!app)
        app = "";
    pop = window.open(app+"Checkout/Index.aspx","pop","width=700,height=500,scrollbars=1,resizable=1");
    pop.document.location.reload();pop.focus();
   
    
}
//window.attachEvent("onunload",closepop);
addEvent(window,"unload",closepop);
function closepop()
{  // alert('closing');
    if(pop) pop.close();
}

function Shopcart(app)
{   if(!app)
        app = "";
    pop = window.open(app+"Shopcart.aspx","pop","width=700,height=500,scrollbars=1,resizable=1");
    pop.document.location.reload();pop.focus();
   
}

function Login(app)
{   if(!app)
        app = "";
    pop = window.open(app+"Login.aspx","pop","width=700,height=450,resizable=1");
pop.document.location.reload();pop.focus();
}

function addtofavorite(url,name,id)
{
    if(confirm("would you like to include your login id, so that next time you only need to type in password.")    ) 
    {window.external.AddFavorite(url+"?id="+id,name);}
    else{window.external.AddFavorite(url,name);}
    return false;
}


function addEvent(target, eventName, handler)
{
    if(window.attachEvent)
        target.attachEvent("on"+eventName, handler);
    else if(document.addEventListener)
        target.addEventListener(eventName,handler,false);
    else
        alert("Your browser does not support functionality of this system. Please use IE6 sp2 or up instead");
}
function getEventSource(event)
{
    if(window.event)
        return window.event.srcElement;
    else if(event.currentTarget)
        return event.currentTarget;
    
    return null;
}

function getKey(keyStroke) {
    var keyCode = (document.layers) ? keyStroke.which : event.keyCode;
     alert(keyCode);
    if (keyCode == 13) {
        var a = document.getElementById('update');
        a.focus();
        if (a) {
            a.click();
        }
    }

}

//non ie
if (document.layers) {
   // document.captureEvents(Event.KEYPRESS);
}

String.prototype.endsWith = function(str) { return (this.match(str + "$") == str) }
String.prototype.startsWith = function(str) { return (this.match("^" + str) == str) }

String.prototype.trim = function() { return (this.replace(/^[\s\xA0]+/, "").replace(/[\s\xA0]+$/, "")) }

//document.onkeypress = getKey;


//-->