/*
pvp

Author: Jonathan Mangano
Dependencies: FastcastMedia.js
*/

/*
 * Opens the legend window
 */
function legend(id) {
	var w=550;
	var h=480;
	var leftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	var topPosition = (screen.height) ? (screen.height-h)/2 : 0;
	var aWindow = window.open('/legend.do?id=' + id,'_blank','width='+w+',height='+h+',scrollbars=no,menubar=no,status=no,resizable=yes,top='+topPosition+',left='+leftPosition+',screenX=0,screenY=60');
	aWindow.focus();
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// Name   : pvpjs_isACCMEBMSDisplay
//
// Desc   : Do we need to call the accme function in order to display ACCME OR BMS PANEL ?
//
//          Based on the fact that the accme.inc is include and if the bussiness rule
//          apply (see accme_isACCMEBMSDisplay in accme.inc).
//          When var accme_inc_loaded it mean that the accme.inc file is include in the document
//
// return : boolean value 
//          true  = the caller must call the appropriate accme function
//          false = the caller must not call a accme function
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function pvpjs_isACCMEBMSDisplay(){
    //alert ("pvp.js().pvpjs_isACCMEBMSDisplay(): typeof accme_inc_loaded="+typeof accme_inc_loaded);
	if (typeof accme_inc_loaded == "undefined" ){
      return false;	
	}  else  {
		return accme_isACCMEBMSDisplay();
	} 
}


function downloadMp3(url ) {

	if (pvpjs_isACCMEBMSDisplay() == true  ){
		accme_display_fromDownLoadMp3(url );
	} else {
		pvpjs_doDownloadMp3(url);
	}
	
}
function pvpjs_doDownloadMp3(url){
    location = url + '&refid=' + pviReferenceID;
}

function downloadFiles(url) {

	if (pvpjs_isACCMEBMSDisplay() == true  ){
		accme_display_fromDownloadFiles(url);
	} else {
		pvpjs_doDownloadFiles(url);
	}
}
function pvpjs_doDownloadFiles(url) {
	if(isOpenedInNewWindow(url)) {
		openWindow(url + '&refid=' + pviReferenceID,'width=680,scrollbars=yes');
	} else {
		location = url + '&refid=' + pviReferenceID;
	}	
}

function isOpenedInNewWindow(url) {
	return (url.indexOf('/dgc.nsf/html/SlideRedirect_s486_Steinhart.htm') != -1)  || 
		(url.indexOf('/dgc.nsf/html/SlideRedirect_s486_Panaccione.htm') != -1);
}

function acronym(id, topic) {
	var w=550;
	var h=450;
	var leftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    var topPosition = (screen.height) ? (screen.height - h) / 2 : 0;
	var aWindow = window.open('/acronym.jsp?topic=' + topic + '&amp;id=' + id,'acronym','width='+w+',height='+h+',scrollbars=yes,menubar=no,status=no,resizable=yes,top='+topPosition+',left='+leftPosition+',screenX=0,screenY=60');
	aWindow.focus();

}

function openInParentWindow(loc){
	if (self.opener != null) {
        opener.location = loc;
		self.opener.focus();
	} else {
		self.document.location = loc;
	}
}

function getQueryVariable(variable) { 
	var query = window.location.search.substring(1); 
	var vars = query.split('&');
	for (var i=0;i<vars.length;i++) { 
		var pair = vars[i].split('='); 
		if (pair[0] == variable) { 
			return pair[1]; 
		} 
	} 
	return '';
}

function openWindow(url, attribs) {
	var newWind = window.open(url, '', attribs);
	if (newWind.opener == null) {
		window.opener = self;
	}
}


	function changeImages() {
      if (document.images ) {
         for (var i=0; i<changeImages.arguments.length; i+=2) {
            document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
         }
      }
	}


  
