﻿function GetObj( oName, oFrame, oDoc ) {
    /* if not working on a layer, document should be set to the
    document of the working frame
    if the working frame is not set, use the window object
    of the current document
    WARNING: - cross frame scripting will cause errors if
    your page is in a frameset from a different domain */
	if( !oDoc ) {
		if( oFrame ) {
			if (oFrame.contentDocument) {
				oDoc = oFrame.contentDocument;
			} else {
				oDoc = oFrame.document;
			}
		} else {
			oDoc = window.document;
		}
	}

    //check for images, forms, layers
    if( oDoc[oName] ) { return oDoc[oName]; }

    //check for pDOM layers
    if( oDoc.all && oDoc.all[oName] ) { return oDoc.all[oName]; }

    //check for DOM layers
    if( oDoc.getElementById && oDoc.getElementById(oName) ) {
        return oDoc.getElementById(oName); }

    //check for form elements
    for( var x = 0; x < oDoc.forms.length; x++ ) {
        if( oDoc.forms[x][oName] ) { return oDoc.forms[x][oName]; } }

    //check for anchor elements
    //NOTE: only anchor properties will be available,
    //NOT link properties!
    for( var x = 0; x < oDoc.anchors.length; x++ ) {
        if( oDoc.anchors[x].name == oName ) {
            return oDoc.anchors[x]; } }

    return null;
}

function CopyContent ( objSrc, objDest ) {
	if (document.all) {
		objDest.innerHTML = objSrc.outerHTML;
	} else {
		while (objDest.hasChildNodes()) {
			objDest.removeChild(objDest.lastChild);
		}
		objDest.appendChild(document.importNode(objSrc,true));
	}
}
