
var applicationUrl = "";
var contentUrl = "";
var xmlUrl ="";
var applicationSecureUrl = "";
var username = "";
var tourCenterCode = "";
var uid="";
var languageId="";
var language="";
var homepageUrl = "Default.aspx";
var supplierUrl = "SupplierDefault.aspx";
var resourceUrl = "ResourceCenterGroup.aspx";
var salesUS = "http://www.explorica.com"
var salesCA = "http://www.explorica.ca"

var datePickerUrl =  "DatePicker.aspx";
var printTDIUrl = "PrintTDI.aspx";
var busDriverItineraryUrl = "BusDriverItinerary.aspx";
var flightInformationUrl = "FlightInformation.aspx";
var imageViewerUrl = "Viewer.aspx";


// copy from SupplierManagementSystem general.js
// 2008-05-08, lszczecinski
		function GiveMeHelp(section, selection, langID)
        {
            var features = "dependent=yes,menubar=no,width=400,height=300,scrollbars=yes,resizable=yes,top=100,left=200";
            var parameters = "?section=" + section + "&selection=" + selection + "&languageID=" + langID;
            //  var targetUrl = addr + "/" + busDriverItineraryUrl + parameters ;
            var targetUrl = "Help.aspx" + parameters;
  
            window.open(targetUrl , "HelpWindow", features);
        }
       
  // 2008-*--
        function GiveMeHelpExpenses(section, selection, langID)
        {
            var features = "dependent=yes,menubar=no,width=400,height=300,scrollbars=yes,resizable=yes,top=100,left=200";
            var parameters = "?section=" + section + "&selection=" + selection + "&languageID=" + langID;
            //  var targetUrl = addr + "/" + busDriverItineraryUrl + parameters ;
            var targetUrl = "Help.aspx" + parameters;
  
            window.open(targetUrl , "HelpWindow", features);
        }


/*function printTDI( prodTourId ) {

  var features = "dependent=yes,menubar=yes,scrollbars=yes,resizable=yes";
  var parameters = "?ProductionTourId=" + prodTourId ;
  var height= 500;
  var width = 700;
  var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
  }
  window.open( printTDIUrl + parameters, "printTDI", features + str );
}*/
function printTDI(addr, identifier, prodTourId,suppliedComponentID)
{
  var features = "dependent=yes,menubar=yes,width=700,height=500,scrollbars=yes,resizable=yes";
  
  var features = "menubar=yes,scrollbars=yes,resizable=yes";
  var parameters = "?ProductionTourID=" + prodTourId + "&suppliedComponentID=" + suppliedComponentID + "&partneridentifier=" + identifier + "&languageId=11";
  var targetUrl = addr  + "/" + printTDIUrl + parameters ;
  
  window.open(targetUrl , "printTDI", features);
}

function printBDI(addr, supplierReservationID)
{
  var features = "dependent=yes,menubar=yes,width=700,height=500,scrollbars=yes,resizable=yes";
  
  var features = "menubar=yes,scrollbars=yes,resizable=yes";
  var parameters = "?supplierReservationID=" + supplierReservationID + "&languageId=11";
//  var targetUrl = addr + "/" + busDriverItineraryUrl + parameters ;
  var targetUrl = busDriverItineraryUrl + parameters ;
  
  window.open(targetUrl , "BusDriverItinerary", features);
}



function flightInformation(addr, identifier, prodTourId)
{
  var features = "dependent=yes,menubar=yes,width=700,height=500,scrollbars=yes,resizable=yes";
  
  var features = "menubar=yes,scrollbars=yes,resizable=yes";
  var parameters = "?ProductionTourID=" + prodTourId + "&partneridentifier=" + identifier + "&requirementBlockID=";
  var targetUrl = addr + "/" + flightInformationUrl + parameters ;
  window.open( targetUrl, "Flights", features);
}
function flightInformationForShuttle(addr, identifier, requirementBlockId) {
    var features = "dependent=yes,menubar=yes,width=700,height=500,scrollbars=yes,resizable=yes";

    var features = "menubar=yes,scrollbars=yes,resizable=yes";
    var parameters = "?RequirementBlockID=" + requirementBlockId + "&partneridentifier=" + identifier + "&ProductionTourID=";
    var targetUrl = addr + "/" + flightInformationUrl + parameters;
    window.open(targetUrl, "Flights", features);
}

function RoomingViewer(supplierReservationId, suppliedComponentId)
{
  var features = "dependent=yes,menubar=no,width=700,height=500,scrollbars=yes,resizable=yes,toolbar=no";
  var roomingViewerUrl = "RoomingView.aspx";
  //var features = "menubar=yes,scrollbars=yes,resizable=yes";
  var parameters = "?mode=options&supplierReservationID=" + supplierReservationId + "&suppliedComponentID=" + suppliedComponentId;
  window.open( roomingViewerUrl + parameters, "RoomingViewer", features);
}


function ImageViewer( invoiceId, invoiceAttachementId)
{
  var features = "dependent=yes,menubar=no,width=700,height=500,scrollbars=no,resizable=yes,toolbar=no";
  
  //var features = "menubar=yes,scrollbars=yes,resizable=yes";
  var parameters = "?invoiceId=" + invoiceId + "&invoiceAttachmentId=" + invoiceAttachementId ;
  window.open( imageViewerUrl + parameters, "ImageViewer", features);
}

function emailTour( tourId, tourCenterCode, username ) {

  var features = "dependent=yes,width=780,height=400,scrollbars=yes";
  var parameters = "?tourId=" + tourId + "&tourCenterCode=" + tourCenterCode + "&languageId=" + languageId + "&postalCode=" + postalCode;
  
  window.open( applicationUrl + emailTour + parameters, "emailTour", features );
}

function viewMessage( messageId ) {
 
  var features = "dependent=yes,width=780,height=400,scrollbars=yes";
  // window.open( messageUrl + messageId, "message", features );
}



function printWindow()
{
	window.print();
}


function viewDatePicker() {

  var features = "dependent=yes,width=190,height=190,top=200,left=300,scrollbars=no,resizable=no";
  window.open( applicationUrl + datePickerUrl, "viewGroupLeaderRelease", features );
}

function resetForm()
	{
		document.forms[0].reset();
	}
	
function mouseOverCommand( description ) {

  window.status = description;
  return true;
}

function command( url ) {

  location.href = url;
}

function setLanguage( id ) {

 window.location.replace( applicationUrl + homepageUrl  + "?languageId=" + id + "&username=" + username + "&tourCenterCode=" + tourCenterCode);
}
	
function logout() {
  
  window.location.replace('Default.aspx?command=logout&languageId=' + languageId);
  
}
function viewHomepage(isAuthenticated)

{
    
    if (isAuthenticated == true)
    {
      location.href = applicationUrl + supplierUrl + "?mode=servicesList&languageId=" + languageId + "&username=" + username ; 
    }
    else
    {
      location.href = applicationUrl + supplierUrl + "?mode=servicesList&languageId=" + languageId; 
    }
  
}


function viewYourProfile(  )
{
 
    location.href = applicationUrl + homepageUrl + "?mode=profile&languageId=" + languageId + "&username=" + username; 
    
  
}
function viewYourContract(  )
{
 
    location.href = applicationUrl + homepageUrl + "?mode=contract&languageId=" + languageId + "&username=" + username; 
    
  
}
function viewYourServices(  )
{
 
    location.href = applicationUrl + homepageUrl + "?mode=servicesList&languageId=" + languageId + "&username=" + username;
    
  
}
function viewYourSpace(  )
{
 
    location.href = applicationUrl + homepageUrl + "?mode=space&languageId=" + languageId + "&username=" + username;
    
  
}
function viewYourActivity(  )
{
 
    location.href = applicationUrl + homepageUrl + "?mode=activity&languageId=" + languageId + "&username=" + username;
    
  
}
function viewYourAccount(  )
{
 
    location.href = applicationUrl + homepageUrl + "?mode=account&languageId=" + languageId + "&username=" + username ; 
    
  
}

function viewYourTour(  )
{
 
    location.href = applicationUrl + homepageUrl + "?mode=servicesInfo&languageId=" + languageId + "&username=" + username ; 
    
  
}

function viewWorldResourceCenter(isAuthenticated) 
{
 
    if (isAuthenticated == true)
    {
        location.href = applicationUrl + resourceUrl + "?mode=resourceCenter&languageId=" + languageId + "&username=" + username; 
    }
    else
    {
        location.href = applicationUrl + resourceUrl + "?mode=resourceCenter&languageId=" + languageId; 
    }
  
}

function viewWorldSupplierResourceCenter(isAuthenticated) 
{
 
    if (isAuthenticated == true)
    {
        location.href = applicationUrl + resourceUrl + "?mode=resourceCenter&languageId=" + languageId + "&username=" + username; 
    }
    else
    {
        location.href = applicationUrl + resourceUrl + "?mode=resourceCenter&languageId=" + languageId; 
    }
  
}


function viewResourceCenter(isAuthenticated) 
{
 
    if (isAuthenticated == true)
    {
      location.href = applicationUrl + homepageUrl + "?mode=resourceCenter&languageId=" + languageId + "&username=" + username ; 
    }
    else
    {
        location.href = applicationUrl + homepageUrl + "?mode=resourceCenter&languageId=" + languageId; 
    }
  
}

function viewSupplierResourceCenter(isAuthenticated) 
{
 
    if (isAuthenticated == true)
    {
        location.href = applicationUrl + supplierUrl + "?mode=resourceCenter&languageId=" + languageId + "&username=" + username; 
    }
    else
    {
        location.href = applicationUrl + supplierUrl + "?mode=resourceCenter&languageId=" + languageId; 
    }
  
}

function viewNotImplemented(  )
{
 
    location.href = applicationUrl + homepageUrl + "?mode=notImplemented&languageId=" + languageId + "&username=" + username ; 
    
  
}

function viewGeneral(  )
{
    location.href = applicationUrl + supplierUrl + "?mode=general&languageId=" + languageId + "&username=" + username ; 
  
}

function viewPhonebook(  )
{
 
    location.href = applicationUrl + supplierUrl + "?mode=phonebook&languageId=" + languageId + "&username=" + username ; 
    
  
}

function viewServices(  )
{
 
    location.href = applicationUrl + supplierUrl + "?mode=servicesList&languageId=" + languageId + "&username=" + username ; 
    
  
}
function viewAccount(  )
{
 
    location.href = applicationUrl + supplierUrl + "?mode=account&languageId=" + languageId + "&username=" + username ; 
    
  
}

function viewInvoices(  )
{
 
    location.href = applicationUrl + supplierUrl + "?mode=invoices&languageId=" + languageId + "&username=" + username ; 
    
  
}

function viewPayments(  )
{
 
    location.href = applicationUrl + supplierUrl + "?mode=payments&languageId=" + languageId + "&username=" + username ; 
    
  
}

function viewSecurity(  )
{
 
    location.href = applicationUrl + supplierUrl + "?mode=security&languageId=" + languageId + "&username=" + username ; 
    
  
}
function viewTour(  )
{
 
    location.href = applicationUrl + supplierUrl + "?mode=servicesInfo&languageId=" + languageId + "&username=" + username ; 
    
  
}
function SubmitEvaluation( partnerID, languageID,partnerGroupReference,partnerTravelerReference, day, action )
{
    // location.href = roomingUrl + "&action=edit&requirementId=" + requirementId + "&roomAssignmentId=" + roomAssignmentId;
   	
   	var frm = document.forms[0]
	//frm.action= roomingUrl + "&action=" + action +  "&partnerGroupReference=" + partnerGroupReference + "&partnerTravelerReference=" + partnerTravelerReference
	//					+ "&languageID=" + languageID + "&partnerID=" + partnerID + "&day=" + day;
   	frm.submit();
   
}
function EvaluationNavigation(navmode)
{
  document.forms[0].elements['navmode'].value = navmode;
  document.forms[0].elements['action'].value = "save";
  document.forms[0].submit();
  
}
function CloseEvaluationWindow( isInfoSaved , partnerID,  partnerGroupReference, username ) 
{
	//Change close functinality on 7-20-2004 to not close the evaluation popup but to redirect
	//to the sales site.
	/*if(isInfoSaved  == 'True')
	{
		window.close();
	}*/
	var urlRoot = salesUS;
	if (partnerID == 2)	
	{
		urlRoot = salesCA;
	}
	location.href = urlRoot + "/MyExplorica.aspx?mode=tourCenters&username=" + username+ "&tourCenterCode=" + partnerGroupReference;
}


 
    function ShowPopupGrid(el)
    {
        
      var x = el.offsetLeft + (el.offsetWidth/2);
      var y = el.offsetTop + (el.offsetHeight/2);
      var par = el.offsetParent;
      while(par!=null) { x+=par.offsetLeft; y+=par.offsetTop; par=par.offsetParent; }
      document.getElementById("divGrid1").style.top = y;
      document.getElementById("divGrid1").style.left = x;
      document.getElementById("divGrid1").style.display = "block";
    }
    
    function calendarPicker(strfieldID)

            {
                var currentDate = document.getElementById(strfieldID).value;
                window.open('DatePicker.aspx?field=' + strfieldID + '&date=' + currentDate, 'calendarPopup', 'width=250,height=190,resizable=yes');

            }
