//Object Creation
var isDOM, isIE;
//
// Global dialogEvent declaration (Used in popupDialogBox method)
//
var gCallbackEvent = null;

if(document.getElementById) isDOM=true;
if(document.all) isIE=true;

function testForObject(obj, nest) {	
	if(isDOM?document.getElementById(obj):document.all[obj]) return true;
	else return false;
}

function makeLayer(obj) {
					
	this.el=isDOM?document.getElementById(obj):document.all[obj];
	if ( this.el == null ) {
		return null;
	}
	this.css=isDOM?document.getElementById(obj).style:document.all[obj].style;
	this.ref=document;
	this.x=(isDOM && !isIE)?parseInt(this.css.left.substring(0, this.css.left.length-2)):this.css.pixelLeft;
	this.y=(isDOM && !isIE)?parseInt(this.css.top.substring(0, this.css.top.length-2)):this.css.pixelTop;
	this.height=this.el.offsetHeight;
	this.clr=this.css.color;
	   this.bgc=this.css.backgroundColor;
	this.hideIt=b_hideIt; this.showIt=b_showIt; this.greyIt=b_greyIt; 
	this.unGreyIt=b_unGreyIt; this.moveIt=b_moveIt; this.bgOn=b_bgOn; this.bgOff=b_bgOff;							
	return this;
}

function b_showIt(){this.css.visibility="visible";}
function b_hideIt(){this.css.visibility="hidden";}
function b_greyIt(){this.css.color=greycolor;}
function b_unGreyIt(){this.css.color=ungreycolor;}
function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x; this.css.top=this.y;}
function b_bgOn(){this.bgc=bgon; this.css.bgColor=bgon; this.css.backgroundColor=bgon;}
function b_bgOff(){this.bgc=bgoff; this.css.bgColor=bgoff; this.css.backgroundColor=bgoff;}					 

//mouseover layer positioning
function DL_GetElementLeft(el) {
	eElement=document.getElementById(el);  

	var nLeftPos = eElement.offsetLeft;		  // initialize var to store calculations
	var eParElement = eElement.offsetParent;	 // identify first offset parent element  
	while (eParElement != null) {				// move up through element hierarchy
		nLeftPos += eParElement.offsetLeft;	  // appending left offset of each parent
		eParElement = eParElement.offsetParent;  // until no more offset parents exist
	}
	return nLeftPos;							 // return the number calculated
}

function DL_GetElementTop(el) {
	eElement=document.getElementById(el);
	var nTopPos = eElement.offsetTop;			// initialize var to store calculations
	var eParElement = eElement.offsetParent;	 // identify first offset parent element  
	while (eParElement != null) {				// move up through element hierarchy
		nTopPos += eParElement.offsetTop;		// appending top offset of each parent
		eParElement = eParElement.offsetParent;  // until no more offset parents exist
	}
	return nTopPos;							  // return the number calculated
}
  

function showLayer(lyr, obj, xoffset, yoffset) {
  
	var xpos = DL_GetElementLeft(obj);
	var ypos = DL_GetElementTop(obj);
	infoLayer=new makeLayer(lyr);
	infoLayer.moveIt(xpos+xoffset, ypos+ yoffset);
	infoLayer.showIt();
}
function hideLayer(lyr) {
	 infoLayer=new makeLayer(lyr);
	 infoLayer.hideIt();
}


function showMenu(menlyr, parlyr, offset) {
	var xpos = DL_GetElementLeft('menu1');
    if (navigator.platform.indexOf("Mac")> -1 && isIE==true) xpos=0;
	var ypos = DL_GetElementTop(parlyr);
	infoLayer=new makeLayer(menlyr);
	infoLayer.moveIt(xpos, ypos + offset);
    if (navigator.platform.indexOf("Mac")> -1 && isIE != true) 
    {
        var showdelay = setTimeout('showinfoLayer()', 1);
    }
    else infoLayer.showIt();
}

function showinfoLayer()
{
    infoLayer.showIt();
    clearTimeout(showdelay);
}

function hideMenu(lyr) {
	 infoLayer=new makeLayer(lyr);
	 infoLayer.hideIt();
}
//image swapping
var preloadFlag = false;

function newImage(arg) {
	rslt = new Image();
	rslt.src = arg;
	return rslt;
}

function changeImages() {
	if(preloadFlag==true) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
		   document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

//Color Enabling, Disabling
var greycolor="#666666";
var ungreycolor="#000000";
	  
function greyOut(obj, num) {
	 colorChange=new makeLayer(obj + "label" + num);
	 colorChange.greyIt();
}

function unGreyOut(obj, num) {
	 colorChange=new makeLayer(obj + "label" + num);
	 colorChange.unGreyIt();
}
	
function enableRadio(radioname, num) {
	eval('document.form1.'+ radioname + '[num-1]').disabled=false;
}

function disableRadio(radioname, num) {
	eval('document.form1.'+ radioname + '[num-1]').disabled=true;
}

//Dynamic Link Changing
function getLink(where) {
	var returnlink = null;

	if (where=="interior") {
		returnlink = moviedirectory + showint360;
	} else {
		returnlink = moviedirectory + showext360;
	}
	return returnlink;
}

function openWindow( nm, u, w, h, x ) {
	args="width=" + w +",height=" + h + ",resizable=yes,scrollbars=yes,status=0";
	remote=window.open(u,nm,args);
	if (remote != null) {
		if (remote.opener == null)
			remote.opener = self;
	}
	if (x == 1) { return remote; }
}

/*
 * Constructor for Dialog box event
 */
function DialogBoxEvent( id, args ) {

	this.id = id;
	this.usersChoice = false;
	this.argA = args;

	this.callbackMethod = null;
}

//
// Pre-load images
//
var imgC0 = new Image();
var imgC1 = new Image();
var imgC2 = new Image();

imgC0.src = 'images/global/hdr_glo_popup.gif';
imgC0.src = 'images/global/btn_glo_cancel_left.gif';
imgC0.src = 'images/global/btn_glo_ok.gif';

function popupDialogBox( txt ) {
	var args = "width=510,height=250,resizable=0,scrollbars=0,status=0";
	var newindow = window.open('', 'window1', args);

	newindow.opener = self;

	var content = "<html><head><title>Alert</title><link rel='stylesheet' type='text/css' href='style/global.css'>";
	content = content + "\n<style>"
	content = content + "body,p,table,tr,td,ul,ol {"
	content = content + "font-family: verdana, arial, helvetica, sans-serif; "
	content = content + "font-size: 10px; "
	content = content + "font-weight: normal;"
	content = content + "text-decoration: none;"
	content = content + "color: #000000;"
	content = content + "}"
	content = content + "</style>;"
	content = content + "\n<script language='javascript'>";
	content = content + "\nvar selectionMade = false;";
	content = content + "\nfunction dialogBtnClicked( value ) {";
	content = content +		"selectionMade = true;";
	content = content +		"if ( window.opener.gCallbackEvent != null ) {";
	content = content +			"window.opener.gCallbackEvent.usersChoice = value;";
	content = content +			"if ( window.opener.gCallbackEvent.callbackMethod != null ) "
	content = content +				"window.opener.gCallbackEvent.callbackMethod(window.opener.gCallbackEvent);"
	content = content +		"}";
	content = content +		"window.close();";
	content = content + "}";
	content = content + "\n//cheap trick\n";
	content = content + "function refocus() {";
	content = content +		"if ( window.closed ) {";
	content = content +			"if ( selectionMade == false ) {";
	content = content +				"dialogBtnClicked( false );";
	content = content +			"}";
	content = content +			"return;";
	content = content +		"} self.focus();";
	content = content +		"setTimeout('refocus()', 40);";
	content = content + "}\nfunction closeDialog( w ) {";
	content = content + "if ( selectionMade == false ) dialogBtnClicked( false ); }";
	content = content + "refocus();";
	content = content + "</script>";
	content = content + "</head>";
	content = content + "\n<body topmargin='0' leftmargin='0' marginheight='0' marginwidth='0'";
	content = content + " onBlur='self.focus()' onUnload='closeDialog( \"unload\" )' onBeforeUnload='closeDialog(\"beforeUnload\")' >" ;

	content = content + "<table width='498' border='0' cellpadding='0' cellspacing='0'><tr><td colspan='3'><img src='images/global/spacer.gif' width='1' height='10' alt='' border='0'></td></tr><tr><td><img src='images/global/spacer.gif' width='18' height='1' border='0' alt=''></td><td>";
	content = content + "<table width='461' border='0' cellpadding='0' cellspacing='0'><tr class='bgcolor10'><td colspan='5'><img src='images/global/spacer.gif' border='0' width='300' height='1' alt=''></td></tr><tr><td class='bgcolor10' rowspan='100'><img src='images/global/spacer.gif' width='1' height='1' border='0' alt=''></td><td class='bgcolor10' colspan='3'><img src='images/global/spacer.gif' width='459' height='1' border='0' alt=''></td><td class='bgcolor10' rowspan='100'><img src='images/global/spacer.gif' width='1' height='1' border='0' alt=''></td></tr><tr class='bgcolor13'><td colspan='3'><img src='images/global/spacer.gif' width='1' height='10' border='0' alt=''></td></tr><tr class='bgcolor13'><td><img src='images/global/spacer.gif' width='10' height='1' border='0' alt=''></td><td>";
	content = content + "<table width='439' border='0' cellpadding='0' cellspacing='0' class='bgcolor02'><tr><td colspan='4' class='bgcolor02'><img src='images/global/spacer.gif' width='1' height='10' border='0' alt=''></td></tr><tr><td class='bgcolor02'><img src='images/global/spacer.gif' width='10' height='1' border='0' alt=''></td><td colspan='2' class='bgcolor02'>";
	content = content +  txt + "</td><td class='bgcolor02'><img src='images/global/spacer.gif' width='10' height='1' border='0' alt=''></td></tr><tr><td colspan='4' class='bgcolor02'><img src='images/global/spacer.gif' width='1' height='10' border='0' alt=''></td></tr><tr><td class='bgcolor02'><img src='images/global/spacer.gif' width='10' height='1' border='0' alt=''></td><td class='bgcolor02'>";
	content = content + "<a href=# onclick='javascript:dialogBtnClicked( false )'><img src='images/global/btn_glo_cancel2.gif' width='66' height='18' border='0'></a></td><td valign='bottom' align='right' class='bgcolor02'>";
	content = content + "<a href=# onclick='javascript:dialogBtnClicked( true )'><img src='images/global/btn_glo_ok_forward.gif' width='45' height='18' border='0'></a></td><td class='bgcolor02'><img src='images/global/spacer.gif' width='10' height='1' border='0' alt=''></td></tr><tr><td class='bgcolor02'><img src='images/global/spacer.gif' width='10' height='10' border='0' alt=''></td><td class='bgcolor02'><img src='images/global/spacer.gif' width='214' height='1' border='0' alt=''></td><td class='bgcolor02'><img src='images/global/spacer.gif' width='205' height='1' border='0' alt=''></td><td class='bgcolor02'><img src='images/global/spacer.gif' width='10' height='1' border='0' alt=''></td></tr></table>";
	content = content + "</td><td><img src='images/global/spacer.gif' width='10' height='1' border='0' alt=''></td></tr><tr class='bgcolor13'><td colspan='3'><img src='images/global/spacer.gif' width='1' height='10' border='0' alt=''></td></tr><tr class='bgcolor10'><td><img src='images/global/spacer.gif' width='10' height='1' border='0' alt=''></td><td><img src='images/global/spacer.gif' width='439' height='1' border='0' alt=''></td><td><img src='images/global/spacer.gif' width='10' height='1' border='0' alt=''></td></tr></table>";
	content = content + "</td><td><img src='images/global/spacer.gif' width='19' height='1' border='0' alt=''></td></tr><tr><td><img src='images/global/spacer.gif' width='18' height='1' border='0' alt=''></td><td><img src='images/global/spacer.gif' width='1' height='1' border='0' alt=''></td><td><img src='images/global/spacer.gif' width='19' height='1' border='0' alt=''></td></tr></table>";
	content = content + "</body></html>";
	


	newindow.document.open();
	newindow.document.write(content);
	newindow.document.close;
	newindow.focus();

	return newindow;
}


function popuploginalert( txt ) {
	var args = "width=400,height=300,resizable=0,scrollbars=0,status=0";
	var newindow = window.open('', 'window1', args);

	var content = "<html><head><title>Alert</title><link rel='stylesheet' type='text/css' href='style/global.css'>";
	
    
    content = content + "\n<script language='javascript'>";
	
	content = content + "\nfunction gotothatotherpage() {";
	content = content +		"window.opener.location.href='/MusaWeb/displayOwnerMigration.action';"
    content = content +		"window.close();"
	content = content + "}";
	content = content + "</script>";
    
    
    
	content = content + "</head>";
	content = content + "\n<body topmargin='0' leftmargin='0' marginheight='0' marginwidth='0'>";
	content = content + "\n<table width='400' border='0' cellpadding='0' cellspacing='0'><tr><td class='bgcolor01'>";
	content = content + "<img src='images/global/hdr_glo_popup.gif' width='140' height='53' border='0'></td>";
	content = content + "</tr></table>";
	content = content + "<table cellpadding='0' cellspacing='0' border='0' width='370' align='center'><tr>";
	content = content + "<td class='bgcolor10' colspan='5'><img src='images/global/spacer.gif' border='0' width='1' height='2'></td></tr>";
	content = content + "<tr><td class='bgcolor10' width='2' rowspan='2'><img src='images/global/spacer.gif' border='0' width='2'  height='150'></td>";
	content = content + "<td class='bgcolor13' width='2' rowspan='2'><img src='images/global/spacer.gif' border='0' width='15' height='1'></td>";
	content = content + "<td class='bgcolor13' width='336' valign='top'><img src='images/global/spacer.gif' border='0' width='1' height='15'><br>";
	content = content +  txt + "<br><img src='images/global/spacer.gif' border='0' width='1' height='15'></td>"	;
	content = content + "<td class='bgcolor13' width='2' rowspan='2'><img src='images/global/spacer.gif' border='0' width='15' height='1'></td>";
	content = content + "<td class='bgcolor10' width='2' rowspan='2'><img src='images/global/spacer.gif' border='0' width='2' height='3'></td></tr>";
	content = content + "<tr><td class='bgcolor13' valign='bottom' align='center'><img src='images/global/spacer.gif' width='59' height='18' border='0'>";
	content = content + "<img src='images/global/spacer.gif' width='240' height='1' border='0'><a href='#' onclick='window.close()'><img src='images/global/btn_glo_ok.gif' width='37' height='18' border='0'></a><br>";
	content = content + "<img src='images/global/spacer.gif' border='0' width='1' height='10'></td></tr>";
	content = content + "<tr><td class='bgcolor10' colspan='5'><img src='images/global/spacer.gif' border='0' width='1'height='2'></td></tr>";
	content = content + "</table></body></html>";

	newindow.document.open();
	newindow.document.write(content);
	newindow.document.close;
	newindow.focus();

}


