av =navigator.appVersion;

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr;
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
		x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document;
	if(d.images){
		if(!d.MM_p)
			d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){
			d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
		}
	}
}

function MM_findObj(n, d) { //v4.0
	var p,i,x;
	if(!d) d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all)
		x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++)
		x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++)
		x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById)
		x=document.getElementById(n);
	return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3)
		if ((x=MM_findObj(a[i]))!=null) {
			document.MM_sr[j++]=x;
			if(!x.oSrc)
				x.oSrc=x.src; x.src=a[i+2];
		}
}

iMSIE=parseInt(av.indexOf("MSIE"))
	if (iMSIE>=1) {
		if (parseInt(av.charAt(iMSIE+5))<4) {
			window.location = "/common/redirect.html"
		}
		else if (parseInt(av.charAt(iMSIE+5))>=4) {
			browserIE4=true;
		}
	}
	else {
		if (navigator.appName=="Netscape") {
			if (parseInt(av)<4) {
				window.location = "/common/redirect.html"
			}
			else if (parseInt(av)>=4 && parseInt(av)<5) {
				browserNS4=true;
			}
			else if(parseInt(av)>=5 ){
				browserNS6=true;	
			}
		}
	}

function isMacIE(){
	// convert all characters to lowercase to simplify testing
	var agt=navigator.userAgent.toLowerCase();
    
	// *** BROWSER VERSION ***
	var is_major = parseInt(navigator.appVersion);
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));    
	var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
	var is_mac = (agt.indexOf("mac")!=-1);
	if ((is_mac) && (is_ie) && (is_major>=4) && (!is_ie5)) {
		return true;
	}
	else {
		return false;
	}
}

function openWin(title, params, url) {
	window.open(url,title,params)

}

function openGenericPopupWin(sThisURL,psThisWidth,psThisHeight)
 {
 var sThisParams = "toolbar=no,scrollbars=1,resizable=1, menubar=no, width="+psThisWidth+",left =200,top=150,height="+psThisHeight;
 var newLeft = window.width/2;
 var GenericPopupWindow = window.open(sThisURL,"GenericEd",sThisParams);
 GenericPopupWindow.focus();
 }

function returnToOpener(temp) {
	// Make sure the Opener window still exists before setting focus to it
	if (opener != null && !opener.closed) {
		opener.focus();
	}
	window.close();
}

function setStatus(text) {
	self.status = text;
	return true;
}

function unsetStatus() {
	self.status = "";
	return true;
}

function showDescriptionHTTPS(windowTitle, ticketDesc, sellingAgentDir, docRoot) {
	tempWindow = docRoot + "/common/images/blank.gif";
	showIt(windowTitle, ticketDesc, sellingAgentDir, docRoot, tempWindow);
}

function showDescription(windowTitle, ticketDesc, sellingAgentDir,docRoot) {
	showIt(windowTitle, ticketDesc, sellingAgentDir,docRoot, "")
}
function showIt(windowTitle, ticketDesc, sellingAgentDir, docRoot, tempWindow) {
	//set the sellingAgentRoot to the parameter
	
	sellingAgentRoot = docRoot + "/sellingagents/" + sellingAgentDir;

	styleSheetString = sellingAgentRoot+'/css/rialtoStyle.css';
	
	blankgifPath = docRoot + "/common/images/blank.gif";

	imageString = sellingAgentRoot;

	ticketDescWindow=window.open(tempWindow, 'ticket_desc', 'top=250,left=250,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,height=190,width=311');

	ticketDescWindow.document.write("<head>")
	ticketDescWindow.document.write("<title>" + windowTitle + "</title>")
	//ticketDescWindow.document.write("<script language='javaScript' src='js/generic.js'></script>")


	ticketDescWindow.document.write("<link rel='stylesheet' type='text/css' href="+styleSheetString+">")
	ticketDescWindow.document.write("</head>")

	ticketDescWindow.document.write("<body marginwidth='0' marginheight='0' leftmargin='0' topmargin='0'>")

	ticketDescWindow.document.write("<table border='0' cellspacing='0' cellpadding='0' width='295' height='190'>")
		ticketDescWindow.document.write("<tr><td valign='top'>")

			ticketDescWindow.document.write("<table border='0' cellspacing='0' cellpadding='0' width='295' height='190'>")
				ticketDescWindow.document.write("<tr><td width='10' height='1' border='0' class='ppHead'><img src='" + blankgifPath + "' width='10' height='1' border='0'></td>")
				ticketDescWindow.document.write("<td width='200' height='1' class='ppHead'><img src='" + blankgifPath + "' width='200' height='1' border='0'></td>")
				ticketDescWindow.document.write("<td width='10' height='1' border='0' class='ppHead'><img src='" + blankgifPath + "' width='10' height='1' border='0'></td></tr>")

				ticketDescWindow.document.write("<tr><td width='10' class='ppHead'><img src='" + blankgifPath + "' width='10' height='20' border='0'></td>")
				ticketDescWindow.document.write("<td height='15' valign='top' class='ppHead'>"+ windowTitle +"</td>")
				ticketDescWindow.document.write("<td width='10' class='ppHead'><img src='" + blankgifPath + "' width='10' height='20' border='0'></td></tr>")

				ticketDescWindow.document.write("<tr><td width='10' valign='top'><img src='" + blankgifPath + "' width='10' height='10' border='0'></td>")
				ticketDescWindow.document.write("<td height='10' valign='top'><img src='" + blankgifPath + "' height='10' border='0'></td>")
				ticketDescWindow.document.write("<td width='10' valign='top'><img src='" + blankgifPath + "' width='10' height='10' border='0'></td></tr>")


				ticketDescWindow.document.write("<tr><td width='10' valign='top'><img src='" + blankgifPath + "' width='10' height='100' border='0'></td>")
				ticketDescWindow.document.write("<td valign='top' class='ppSText'>")
					ticketDescWindow.document.write(ticketDesc)
				ticketDescWindow.document.write("</td>")
				ticketDescWindow.document.write("<td width='10' valign='top'><img src='" + blankgifPath + "' width='10' height='100' border='0'></td></tr>")

				ticketDescWindow.document.write("<tr><td width='10' valign='bottom'><img src='" + blankgifPath + "' width='10' height='45' border='0'></td>")

						ticketDescWindow.document.write("<td align='right' valign='middle'>")
							ticketDescWindow.document.write("<a onClick='this.href=\"javaScript:window.close()\"' href='' onMouseOver='closeButton.src=\""+imageString+"/images/b_close_r.gif\"' onMouseOut='closeButton.src=\""+imageString+"/images/b_close.gif\"'><img src=\""+imageString+"/images/b_close.gif\" border='0' name='closeButton'></a>")

				ticketDescWindow.document.write("</td><td width='10' valign='bottom'><img src='" + blankgifPath + "' width='10' height='45' border='0'></td></tr>")

				ticketDescWindow.document.write("<tr><td height='5'></td></tr>")

			ticketDescWindow.document.write("</table>")

		ticketDescWindow.document.write("</td></tr>")
	ticketDescWindow.document.write("</table>")

	ticketDescWindow.document.write("</body>")
	ticketDescWindow.document.write("</html>")
}
