var sitewindow = "StoneAudio"
var siteurl = "http://192.168.1.101/stone5/frames.asp";
var win = window
var ic = new Array();
var imgindex = 0;
function openLink(e) {
    var itm = null;
    if (e.srcElement!=null) {
        itm = e.srcElement;
	e.returnValue = false;
	e.cancelBubble = true;

    }
    else{
        itm = e.target;
	e.stopPropagation();
    }
    if(itm!=null){
        if(parent.window.frames["mainframe"]!=null){
            parent.window.frames["mainframe"].open(itm.href,"mainframe");
            
        }
        
    }
    return false;
}

function rowHighlight(e){
    var itm = null;
    var lnk = null;
    if (e.srcElement != null) {
        itm = e.srcElement;
    }
    else {
        itm = e.target;
    }
    if (itm != null)
    {
        switch(itm.tagName) {
            case "TD":
                itm = itm.parentNode;
                break;
            case "A":
                itm = itm.parentNode.parentNode;
                break;
        }
        if (itm != null)itm.className = "hl";
    }
}

function removeHighlight(e){
    var itm = null;
    if (e.srcElement != null) {
        itm = e.srcElement;
    }
    else {
        itm = e.target;
    }
    if (itm != null) {
        switch(itm.tagName) {
            case "TD":
                itm = itm.parentNode;
                break;
            case "A":
                itm = itm.parentNode.parentNode;
                break;
        }
        if (itm != null) itm.className = "";
    } 
}

function validatepage(){
    window.open("http://validator.w3.org/check?uri="+window.location,"mainframe");
}
function VerifyLocation(windowname){
    var ourl = window.location;
    
    if(self.window.name==windowname){
        if(top.window.name!=sitewindow){
            toplevel = FindTopLevelWindow();
            if(toplevel!=null){
                if(ourl.href.indexOf("menu2.asp")>0 || ourl.href.indexOf("unav.asp")>0 || ourl.href.indexOf("frames.asp")>0){
			        toplevel.location.replace(siteurl);
	            }
	            else{
           		    toplevel.location.replace(siteurl+"?redirect="+ourl);
	            }
            }
        }
    }
    else{

        toplevel = FindTopLevelWindow();
        toplevel.name = sitewindow;
        if(toplevel!=null){
            if(ourl.href.indexOf("menu2.asp")>0 || ourl.href.indexOf("unav.asp")>0 || ourl.href.indexOf("frames.asp")>0){
			        toplevel.location.replace(siteurl);
	            }
	            else{
           		    toplevel.location.replace(siteurl+"?redirect="+ourl);
	            }
        }
    }
}

function Select(itm){
    var item = null;
    item = getObjectById(itm);
   
    if(item!=null){

        if(item.parentNode.parentNode.tagName.toLowerCase()=="tr"){
            pobj = item.parentNode.parentNode;
            tobj = item.parentNode.parentNode.parentNode;
            for(n = 1; n<tobj.childNodes.length;n++){
                tobj.childNodes[n].className = "";
            }
            pobj.className="sa_selected";

        }
        item.checked = true;
    }
}

function FindTopLevelWindow(){
    if(win!=top){
        if(win.parent == top){
	        win = win.parent;
        }
        else{
            var istarget = false;
            do{
                win = win.parent
	            if(win==top){
                    istarget = true;
                }
            }
            while(istarget == false);
        }
    }
	return win;    
}

if(navigator.appName=="Microsoft Internet Explorer")
{
    //document.oncontextmenu = rc_eventhandler;
    document.ondragstart = eventhandler;
    document.onselectstart = eventhandler;

    document.onload=setup


}
function setup(){
    try {
  document.execCommand("BackgroundImageCache", false, true);
  
} catch(err) {}
}
function eventhandler(){
    var result = false;
    var tag = document.activeElement.tagName;
    if(tag=="INPUT"||tag=="TEXTAREA"||tag=="A"||tag.className=="selectable"){
        result = true;
    }
    return result;
}

function rc_eventhandler(){
    var result = false;
    var tag = document.activeElement.tagName;
    if(tag=="INPUT"||tag=="TEXTAREA"||tag=="A"||tag.className=="selectable"){
        result = true;
    }
    return result;
}
function calculateBgY(oElement) {
	return document.body.scrollTop - getOffsetTop(oElement);
}

function getOffsetTop(oElement) {
	var iResult= oElement.offsetTop;
	while (oElement.offsetParent) {
		oElement = oElement.offsetParent;
		iResult += oElement.offsetTop;
	}
	return iResult;
}

function getObjectById(id){
    itm = null
    
    if(document.getElementById){
        itm = document.getElementById(id);
    }
    else if(document.all){
        itm = document.all.item(id);
    }
    return itm;
}

function navlink(url, target){
    alert(url+" "+target);
}
function NavigateLink(url, frame){
    if(top.frames["frame"]!=null){

    top.frames[frame].location.href = url;

    }
    else{
    top.mainframe.location.href=url;
    }
    return false;
}
function NavWindow(url, target){
    window.open(url, target);
    return false;
}
function NavLink(url, target){
    window.open(url, target);
    return false;
}