//File Name: sieOpen.js. Created On: 5/31/05.
/**
Function to set the previously viewed SIE.
*/
function setPrevViewed()
{
	        var previousvalue, nextvalue, sieinfoid,pageopenmode,prevnexttype=false;
		if(request.getParameter("PageOpenMode") != null)
			pageopenmode = request.getParameter("PageOpenMode");
		else if(this.document)
			pageopenmode = this.document.sienew.hdradiobutton.value;
		if(request.getParameter('sieinfoid') != null)
			sieinfoid = request.getParameter('sieinfoid');
		if(request.getParameter("prevnexttype") != null)
			prevnexttype = request.getParameter("prevnexttype");
		if(request.getParameter('prev') != null)
			previousvalue   = request.getParameter('prev');
		if(request.getParameter('next') != null)
			nextvalue = request.getParameter('next');
		url = sieinfoid+ ".html?sieinfoid=" + sieinfoid + "&prevnexttype=" + prevnexttype + "&prev=" +previousvalue+ "&next="+ nextvalue +"&PageOpenMode=" + pageopenmode;
		/*
		if(!window.opener.closed)
		{
		*/	
		if(event.type=='unload'){
			 return;
 		 }			
		if (event.clientY < 0) {
				var PagesOpened = session.getAttribute('PagesOpened')-1;
				session.setAttribute('PagesOpened', PagesOpened);
			}	
		//}
}
/**
	Function to set the SIE Page height  according to windows resolution.
*/
function fncGetSieHeight()
{
	var winType = window.navigator.userAgent;	
	var screen_width=window.screen.width;
	var screen_height=window.screen.height;
	var subwindheight='';
	if(winType.indexOf("MSIE 5.5") != -1)
	{
		subwindheight = 650;
		if(screen_width<=800){
			subwindheight = 482;
		}
	}else
	{
		subwindheight = 642;
		if(screen_width<=800){
			subwindheight = 476;
		}
	}
	return subwindheight;		
}
/**
	Function to open the SIE page on click of the link from sie list with defined size and position.
*/
function fncSieOpen(url) {
	
		url=url+"&PageOpenMode=";
		url=url+this.document.sietree.checkboxvalue.value;
		//var winName = "SubWindow";
		var winName = "ESMSUB";
		var screen_width=window.screen.width;
		var screen_height=window.screen.height;

		var subwintop = window.parent.frames(0).screenTop;
		var subwinleft = window.parent.screen.width - 792;
		var subwinwidth = 780;
		//var subwinheight = window.parent.frames(3).screenTop -(subwintop * 2) - 4;
		var subwinheight = fncGetSieHeight();
		if(screen_width<=800)		{
			var subwintop = window.parent.frames(0).screenTop;
			var subwinleft = window.parent.screen.width - 752;
			var subwinwidth = 740;
			//var subwinheight = window.parent.frames(3).screenTop -(subwintop * 2) - 4;
			var subwinheight = fncGetSieHeight();
		}else if(screen_height<=600)		{
		subwinwidth = 710;
			//subwinheight = 478;
			subwinheight = fncGetSieHeight();
			subwinleft = 78;
			subwintop = 25;  
		
		}
		var option = "toolbar=no,location=no,direcries=no,status=no,menubar=no, ";
		option+="scrollbars=yes,resizable=yes,width="+subwinwidth+",height="+subwinheight+",left="+subwinleft+",top="+subwintop; 

		var oWin = window.open(url,winName,option);
		oWin.focus();
		var PagesOpened = session.getAttribute('PagesOpened')+1;
		session.setAttribute('PagesOpened', PagesOpened);

}
/**
	Function to open SIE page from link portal result screen. like can, dtc and monitor search result page with defined size and position.
*/
function fncSieOpenLinkPortal(url){
	var winName = "ESMSUB";
	var screen_width=window.screen.width;
	var screen_height=window.screen.height;
	var subwintop =28;
	var subwinleft = 232;
	var subwinwidth = 780;
	//var subwinheight = 644;
	var subwinheight = fncGetSieHeight();
	if(screen_width<=800)		{
		var subwintop =28;
		var subwinleft = 48;
		var subwinwidth = 740;
		//var subwinheight = 476;
		var subwinheight = fncGetSieHeight();
	}else if(screen_height<=600)		{
		subwinwidth = 710;
		//subwinheight = 478;
		subwinheight = fncGetSieHeight();
		subwinleft = 78;
		subwintop = 25;  		
	}
	var option = "toolbar=no,location=no,direcries=no,status=no,menubar=no, ";
	option+="scrollbars=yes,resizable=yes,width="+subwinwidth+",height="+subwinheight+",left="+subwinleft+",top="+subwintop; 

	var oWin = window.open(url,winName,option);
	oWin.focus();
}
/**
	Function to open SIE page from consult result screen. like can, dtc and monitor search result page with defined size and position.
*/
function fncOpenConsultSie(url,dtcflag) {
		url=url+"&PageOpenMode=";
		url=url+this.document.sietree.checkboxvalue.value;
		var PageOpenMode = this.document.sietree.checkboxvalue.value;
		//var winName = "SubWindow";
		var winName = "ESMSUB";		
		var screen_width=window.screen.width;
		var screen_height=window.screen.height;
		var subwintop =28;
		var subwinleft = 232;
		var subwinwidth = 780;
		//var subwinheight = 644;
		var subwinheight = fncGetSieHeight();
		if(screen_width<=800)		{
			var subwintop =28 ;
			var subwinleft = 48;
			var subwinwidth = 740;
			//var subwinheight = 476;
			var subwinheight = fncGetSieHeight();
		}else if(screen_height<=600)		{
			subwinwidth = 710;
			//subwinheight = 478;
			subwinheight = fncGetSieHeight();
			subwinleft = 78;
			subwintop = 25;  
		
		}
	if( dtcflag == true){
		var subwintop =400;
		var subwinleft = 208;
		var subwinwidth = 804;
		var subwinheight = 300;
		if(screen_width<=800 || screen_height<=600) {
			var subwintop =312;
			var subwinleft = 162;
			var subwinwidth = 628;
			var subwinheight = 235;
		}
		var option = "toolbar=no,location=no,direcries=no,status=no,menubar=no, ";
		option+="scrollbars=yes,resizable=yes,width="+subwinwidth+",height="+subwinheight+",left="+subwinleft+",top="+subwintop; 

		var oWin = window.open(url,winName,option);
		oWin.focus();
	}else
	{
		 //winName = "CONSULTWIN";		
		var option = "toolbar=no,location=no,direcries=no,status=no,menubar=no, ";
		option+="scrollbars=yes,resizable=yes,width="+subwinwidth+",height="+subwinheight+",left="+subwinleft+",top="+subwintop; 


		var oWin = window.open(url,winName,option);
		oWin.focus();
		//window.parent.close();
	}
}
function fnCheckBox(chkval,val)
{

var open=val;

	if(open==1)
		this.document.sietree.checkboxvalue.value=1;
	else
		this.document.sietree.checkboxvalue.value=0;
		
}
/**
	Function to set the page mode button images in sie list page.
*/
function fnEnableDisableImg(thisImg,otherImg,val)
{
	session.setAttribute("OpenNewWindow",val);
	session.setAttribute("PageOpenMode",val);
	var open=val;

	if(open==1)
	{
		this.document.sietree.checkboxvalue.value=1;
		thisImg.src="../images/Open_new_window_t_c.jpg";
		otherImg.src="../images/Renew_window_t.jpg";
	}	
	else
	{
		this.document.sietree.checkboxvalue.value=0;
		thisImg.src="../images/Renew_window_t_c.jpg";
		otherImg.src="../images/Open_new_window_t.jpg";
	}
}
/**
	Function to set the page mode button images in sie list page according to previously set value.
*/
function fnCheckStateAndDisable(thisImg,otherImg)
{
	if(thisImg.name=="compare" && (this.document.sietree.checkboxvalue.value==0 || this.document.sietree.checkboxvalue.value=="0"))
		fnshowDefault(thisImg);
	else if(thisImg.name=="overWrite" && (this.document.sietree.checkboxvalue.value==1 || this.document.sietree.checkboxvalue.value=="1"))
		fnshowDefault(thisImg);
	else if(thisImg.name=="overWrite" && (this.document.sietree.checkboxvalue.value==0 || this.document.sietree.checkboxvalue.value=="0"))
		fnChangeImgOnClick(thisImg);
	else if(thisImg.name=="compare" && (this.document.sietree.checkboxvalue.value==1 || this.document.sietree.checkboxvalue.value=="1"))
		fnChangeImgOnClick(thisImg);
}
/**
	Function to set the page mode button images in sie list page on mouse over
*/
function fnchangeImg(img)
{
if(img.name=='compare')
	if(document.sietree.checkboxvalue.value==1 || document.sietree.checkboxvalue.value=="1")
		img.src="../images/Open_new_window_t_c.jpg";
	else
	img.src="../images/Open_new_window_t_f.jpg";
if(img.name=='overWrite')
	if(document.sietree.checkboxvalue.value==0 || document.sietree.checkboxvalue.value=="0")
		img.src="../images/Renew_window_t_c.jpg";
	else
	img.src="../images/Renew_window_t_f.jpg";
if(img.name=='btnTitle')
img.src="../images/Show_Title_f.jpg";
if(img.name=='btnAll')
img.src="../images/Show_Detail_f.jpg";
}
/**
	Function to set the page mode button images in sie list page on mouse out.
*/
function fnshowDefault(img)
{
if(img.name=='compare')
img.src="../images/Open_new_window_t.jpg";
if(img.name=='overWrite')
img.src="../images/Renew_window_t.jpg";
if(img.name=='btnTitle')
img.src="../images/Show_Title.jpg";
if(img.name=='btnAll')
img.src="../images/Show_Detail.jpg";
}
/**
	Function to set the page mode button images in sie list page on mouse click.
*/
function fnChangeImgOnClick(img){
if(img.name=='btnTitle')
img.src="../images/Show_Title_c.jpg";
if(img.name=='btnAll')
img.src="../images/Show_Detail_c.jpg";
if(img.name=='compare')
img.src="../images/Open_new_window_t_c.jpg";
if(img.name=='overWrite')
img.src="../images/Renew_window_t_c.jpg";
}