var gApplication	= ''
try {gApplication = window.external.Pop('AppID');} catch(e) {
	try {gApplication = window.external.ppkGetIdentValue("Application")} catch(e) {}
}		
var NSP = false;
if ((top.location != self.location) && (gApplication=='PPKOPAS')) NSP = true;

// Change the action of a table type button
function UNUSEDBtnChange(Row,SkinPath,Action) {
	var zAction = Action
	if (zAction != '') zAction = '_'+zAction
	
	//if (navigator.appName == "Microsoft Internet Explorer") {
	//    if (Obj = Row.all.BtnLeft)  {Obj.src = SkinPath+'btnl'+zAction+'.gif';}
	//    if (Obj = Row.all.BtnMain)  {Obj.background = SkinPath+'btnc'+zAction+'.gif';}
	//    if (Obj = Row.all.BtnRight) {Obj.src = SkinPath+'btnr'+zAction+'.gif';}
	//} else {
		var alltags = Row.getElementsByTagName("*")
		for (var i=0; i < alltags.length; i++) {
			var obj = alltags[i]
			switch (obj.id) {
			case 'BtnLeft': obj.src=SkinPath+'btnl'+zAction+'.gif'; break;
			case 'BtnMain': obj.style.background = "url(" + SkinPath+'btnc'+zAction+'.gif' + ")"; break;
			case 'BtnRight' : obj.src=SkinPath+'btnr'+zAction+'.gif'; break;
			default: break;
			}
		}
	//}
}

// Preload table-type buttons
function preloadButton(pButton,pImagePath) {
	var z = String(pImagePath.toUpperCase())
	if (z.indexOf('PPKSTD')!=-1) return

	var zPath = pImagePath + pButton + '/'
	var d=document; 
	if(d.images) { 
		if(!d.MM_p) d.MM_p=new Array();
		var i
		var j=d.MM_p.length
		d.MM_p[j]=new Image; d.MM_p[j++].src=zPath + 'btnl.gif';
		d.MM_p[j]=new Image; d.MM_p[j++].src=zPath + 'btnl_over.gif';
		d.MM_p[j]=new Image; d.MM_p[j++].src=zPath + 'btnl_down.gif';
		d.MM_p[j]=new Image; d.MM_p[j++].src=zPath + 'btnl_dis.gif';
		d.MM_p[j]=new Image; d.MM_p[j++].src=zPath + 'btnc.gif';
		d.MM_p[j]=new Image; d.MM_p[j++].src=zPath + 'btnc_over.gif';
		d.MM_p[j]=new Image; d.MM_p[j++].src=zPath + 'btnc_down.gif';
		d.MM_p[j]=new Image; d.MM_p[j++].src=zPath + 'btnc_dis.gif';
		d.MM_p[j]=new Image; d.MM_p[j++].src=zPath + 'btnr.gif';
		d.MM_p[j]=new Image; d.MM_p[j++].src=zPath + 'btnr_over.gif';
		d.MM_p[j]=new Image; d.MM_p[j++].src=zPath + 'btnr_down.gif';
		d.MM_p[j]=new Image; d.MM_p[j++].src=zPath + 'btnr_dis.gif';
	}
}   		

// Get the attribute of a specific stylesheet class		
function getStyleValue(pClass, pAttribute) {
    var zRetValue = '';
    try {
		if (document.styleSheets.length == 0) return zRetValue;

		var zClass = pClass.toUpperCase();
		var zRules = 'rules';
		if (document.styleSheets[0].cssRules) zRules = 'cssRules';

    
		for(var j=0;j< document.styleSheets.length;j++)
		{
			var objStyle = document.styleSheets[j];
			for(var i=0;i< eval('objStyle.' + zRules + '.length');i++)
			{
				var zStyleClass = eval('objStyle.' + zRules + '[' + i + '].selectorText');
				var zTest = zStyleClass.toUpperCase()
				if (zTest == zClass) {
					var zAttrValue = eval('objStyle.' + zRules + '[' + i + '].style.' + pAttribute)
					if (zAttrValue) {if (zAttrValue != '') zRetValue = zAttrValue;}
				}
			}
		}
    } catch (e) {}
    return zRetValue;
}

var subWin
function ShowWindow(Url,h,w,modal,resize)
{
	if (subWin) subWin.close();

	var isNav = false;
	if (navigator.appName == "Netscape") isNav = true;

	if (resize == true) {
		zResize = 1
		zResizable = 'yes'
	} else {
		zResize = 0
		zResizable = 'no'		
	}

      winLeft = (screen.availWidth - w)/2;
      winTop = (screen.availHeight - h)/2;

	if (isNav) {
	      if (modal==true)
	      {
	        subWin = window.open(Url,"subwin","scrollbars=0,modal=1,resizable="+zResize+",height="+h+",width="+w+",toolbar=0,directories=0,menubar=0,status=0,location=0,left="+winLeft+",top="+winTop,false);
	      }
	      else
	      {
	        subWin = window.open(Url,"subwin","scrollbars=0,modal=0,resizable="+zResize+",height="+h+",width="+w+",toolbar=0,directories=0,menubar=0,status=0,location=0,left="+winLeft+",top="+winTop,false);
	      }
	} else {
	      if (modal==true)
	      {
 		subWin = window.showModalDialog(Url,"","dialogHeight: " + h + "px;dialogWidth: " + w + "px;scroll: No;dialogTop: px; dialogLeft: px; center: Yes; help: No; resizable: "+zResizable+"; status: No;");
	      }
	      else
	      {
	        subWin = window.open(Url,"subwin","scrollbars=0,modal=0,resizable="+zResize+",height="+h+",width="+w+",toolbar=0,directories=0,menubar=0,status=0,location=0,left="+winLeft+",top="+winTop,false);
	      }
	
	}
}
function GetNodeText(Xml,XPath,Default) {
	var result;
	try {
		result = Xml.selectSingleNode(XPath).text;
		if (result == undefined)
		result = Default;
	} catch (e) {
		if (Default!=undefined) result = Default;
		else result = '';
	}
	return result;
}
			
function ShowAccount(LogCode,FullName,DataBase) {
	// Make it the same height and width of calling window
	var win = parent
	if (NSP) win = self
	var obj = getWindowDetails(win)
	ShowUniversalModalWindowPath(CONST_OpacWebDll,self,'AccountAb?XFile=Account&LoginCAb='+LogCode+'&ConsultCAb='+LogCode+'&DataBaseNames='+DataBase,LANG_Consult,obj.height,obj.width,'r','F',obj.top,obj.left);
}
function Login() {
	var zLink = 'GlobalInfo?XFile=LoginAb&Init=T&Action=ShowAccount&ChooseBase=T' + CONST_AllParams + getOpacParams()
	ShowUniversalModalWindowPath(CONST_OpacWebDll,self,zLink,encodeUtf8(LANG_UserId),'310','500','r','T');
}
function reloadMeLeft(pValue) {
	if (NSP) {	
		window.parent.location = CONST_Bib + pValue + '/indexClient.asp?Lang=' + pValue + '&Skin='+CONST_Skin+'&HomePage=F' //+CONST_Params
	} else {
		window.parent.location = CONST_Bib + pValue + '/indexClient.asp?Lang=' + pValue + '&Skin='+CONST_Skin //+CONST_Params
	}
}
function reloadMeCenter(pValue) {
	var wp = window.parent
	wp = wp.parent

	if (NSP) {
		self.location = CONST_Bib + pValue + '/' + returnNSP(pValue) + '?Lang=' + pValue  + '&Skin='+CONST_Skin;
	} else {
		wp.location = CONST_Bib + pValue + '/indexClient.asp?Lang=' + pValue + '&Skin='+CONST_Skin+CONST_Params
	}
}

// Pour NSP
function RDURL(pURL) {
	var RechercheDoc = pURL
	if (NSP) {
		RechercheDoc = RechercheDoc.split('&').join('amp;')
		RechercheDoc = RechercheDoc.replace('?','qm;')
		RechercheDoc = CONST_Site + 
						"IndexFrame.asp?" + 
						"HomePage=F" + 
						"&Lang="+CONST_Lang + 
						"&Skin="+CONST_Skin + 
						"&url=" + 
						RechercheDoc
	}
	return RechercheDoc
}

