//------- Handle the online window
var windowonline=null;

//------- Used to log on to the site
function DoLogOn()
{
  if ((document.all.UserName.value=="") || (document.all.UserPassword.value=="")) 
  {
	return;
  }
  
    var d=parent.ResponseFrame.document;
  
  //------- Clear the document
  d.close();
  d.open();

  //--------- page header
  d.writeln('<html>');
  d.charset = "UTF-8";
  d.writeln('<head><title> AccessRights </title></head>');
  d.writeln('<BODY>');
  //--------- Form Header
  d.writeln('<form method="post" name="accessRightsForm" action="/vtlebanon/sitelogonaction.jsp">');
  //--------- Form Body
  //--------- Action
  d.writeln('<input type="hidden" name="Action" value="isAuthenticated">');  
  //--------- User Name
  d.writeln('<input type="hidden" name="UserName" value="'+document.all.UserName.value+'">');
  //--------- Password
  d.writeln('<input type="hidden" name="UserPassword" value="'+document.all.UserPassword.value+'">'); 
  //--------- language
  d.writeln('<input type="hidden" name="Language" value="E">');
  //--------- End Form
  d.writeln('</form>');
  //return;
  //------- submit the form
  d.all.accessRightsForm.submit();
  parent.window.status="User log in page ";
  //-------- End Page
  d.writeln('</body></html>');
}


//----------------------- Main Menu links and function
//------------------------------------------------------
//-------------------------------------------------------
/*function GVProductsClick()
{
  //parent.navigate("GVProducts.html");
  parent.VTServiceCommonFrame.navigate("GVProducts.HTML");
}*/

//------- Called to view the contact us page
function ContactUsClick()
{
  //window.open("ContactUsPage.jsp");
  parent.VTServiceCommonFrame.navigate("ContactUs.HTML");
}

/*function AboutGeovisionClick()
{
  window.open("http://www.Geovision.com.lb");
}*/

/*function SendCommentClick()
{
  //parent.navigate("ContactUsPage.jsp");
  window.open("GVProducts.html");
}*/

function ChangePasswordClick(userName)
{        
  parent.VTServiceCommonFrame.navigate("ChangePassword.jsp?userName="+userName);
}

function SubmitPasswordChanges(doc)
{
  var userName=doc.getElementById("LogIn").value;
  var oldpass=doc.getElementById("OldPass").value;
  var newpass=doc.getElementById("NewPass").value;
  var confnewpass=doc.getElementById("ConfNewPass").value;
  var d=parent.tempframe.document;
  
  //------- Clear the document
  d.close();
  d.open();

  //--------- page header
  d.writeln('<html>');
  d.charset = "UTF-8";
  d.writeln('<head><title> ChangePassword </title></head>');
  d.writeln('<BODY>');
  //--------- Form Header
  d.writeln('<form method="post" name="changepasswordForm" action="/vtlebanon/ChangePasswordPage.jsp">');
  //--------- Form Body
  //--------- Action
  d.writeln('<input type="hidden" name="Action" value="ChangePassword">');  
  //--------- User Name
  d.writeln('<input type="hidden" name="userName" value="'+userName+'">');
  //--------- Old Password
  d.writeln('<input type="hidden" name="OldPass" value="'+oldpass+'">');
  //--------- New Password
  d.writeln('<input type="hidden" name="NewPass" value="'+newpass+'">');
  //--------- Confirmed New Password
  d.writeln('<input type="hidden" name="ConfNewPass" value="'+confnewpass+'">');
  //--------- language
  d.writeln('<input type="hidden" name="Language" value="E">');
  //--------- End Form
  d.writeln('</form>');
  //return;
  //------- submit the form
  d.all.changepasswordForm.submit();
  parent.window.status="Administrator Changing Password";
  //-------- End Page
  d.writeln('</body></html>');

}

//------- Called to view the online page
function ViewOnlineClick()
{
  //parent.VTServiceCommonFrame.navigate("VTServiceHistoryList.jsp");
 //parent.VTServiceCommonFrame.navigate("GVProducts.HTML");
   var ONwidth=screen.availWidth;
   var ONheight=screen.availHeight;
   /*ONwidth=976;
   ONheight=510;*/
   ONwidth=1015;
   ONheight=660;
   if (windowonline!=null)//&& windowonline.open
  {
    windowonline.close("/vtlebanon/vtlebanonon/Home_E.html");
  }
  //windowonline =window.open("http://st36/683on/Home.html?VTUserID="+VTUserID+",isValid="+isValid+",","","top=0, left=0 ,width="+ONwidth+" ,height="+ONheight+",resizable=yes,status=yes,menubar=no,scrollbars=yes,toolbar=no,fullscreen=no,titlebar=no ");
  //windowonline =window.open("/683/683on/Home.html?VTUserID="+VTUserID+",","","top=0, left=0 ,width="+ONwidth+" ,height="+ONheight+",resizable=yes,status=yes,menubar=no,scrollbars=yes,toolbar=no,fullscreen=no,titlebar=no ");
  windowonline =window.open("/vtlebanon/vtlebanonon/Home_E.jsp","","top=0, left=0 ,width="+ONwidth+" ,height="+ONheight+",resizable=no,status=yes,menubar=no,scrollbars=yes,toolbar=no,fullscreen=no,titlebar=no ");
  
}

//------- RSZ view conline crystal report 18/9/2006
function ViewOnlineReportClick()
{
   var tempVar=1; 
   parent.VTServiceCommonFrame.navigate("onlineReports/VTServiceOnlineReports.jsp?xyz="+tempVar);
}

//------- Called to view all reports  
function ViewReportListClick()
{
  parent.VTServiceCommonFrame.navigate("VTServiceReportsList.jsp?Vehicle=null&StartDate=null&EndDate=null");

}

//------- Called to view onme selected report
function ViewMyReport(aURL)
{   
  //parent.navigate("VTServiceReport.jsp?ZipFileName="+aURL); 
  window.open("VTServiceReport.jsp?ZipFileName="+aURL); 
}

//------- Called to download one selected report
function DownloadReport(aURL)
{  
  //document.location.replace(aURL);
  //alert(aURL);  
  //alert("C:/gv-prj/vtlebanon/vtlebanonSoftware/"+aURL);
  window.open("Reports/"+aURL);
  
}

 //------- To ajust the date 
 function calcDate(startD)
  {
	var ind1 = startD.indexOf("/");
	var mm= startD.substring(0,ind1);
	var ind2= startD.indexOf("/",ind1+1);
	var dd= startD.substring(ind1+1,ind2);
	var yy= startD.substring(ind2+1);
	mm="0"+mm;
	if (mm.length==3) mm=mm.substr(1,2);
	dd="0"+dd;
	if (dd.length==3) dd=dd.substr(1,2);
	startD=mm+"/"+dd+"/"+yy;
	return startD;
  }


//------- Called to submit the changes mad to the report
function doSubmitReportChanges(doc,userid)
{
  var vehicle=doc.all.VehicleList.value;
  var startDate=doc.all.StartDate.value;
  var endDate=doc.all.EndDate.value;
  /*var startD=document.all["StartDate"].value;
	  document.all["StartDate"].value=calcDate(startD);


	  var endD=document.all["EndDate"].value;
	  document.all["EndDate"].value=calcDate(endD);*/
  startDate=calcDate(startDate);
  endDate=calcDate(endDate);  

  //alert(vehicle);
  //alert(startDate);
  //alert(endDate);
  //parent.VTServiceCommonFrame.navigate("/683/ContactUs.html");
  
  var d=parent.VTServiceCommonFrame.document;
  
  //------- Clear the document
  d.close();
  d.open();

  //--------- page header
  d.writeln('<html>');
  d.charset = "UTF-8";
  d.writeln('<head><title> SubmitReport </title></head>');
  d.writeln('<BODY>');
  //--------- Form Header
  d.writeln('<form method="post" name="SubmitReportForm" action="/vtlebanon/VTServiceReportsList.jsp">');
  //--------- Form Body
  //--------- Action
  d.writeln('<input type="hidden" name="Action" value="SubmitReport">');  
  //--------- User Id
  d.writeln('<input type="hidden" name="UserId" value="'+userid+'">');
  //--------- Vehicle
  d.writeln('<input type="hidden" name="Vehicle" value="'+vehicle+'">');
  //--------- Start Date
  d.writeln('<input type="hidden" name="StartDate" value="'+startDate+'">');
  //--------- End Date
  d.writeln('<input type="hidden" name="EndDate" value="'+endDate+'">');
  //--------- language
  d.writeln('<input type="hidden" name="Language" value="E">');
  //--------- End Form
  d.writeln('</form>');
  //return;
  //------- submit the form
  d.all.SubmitReportForm.submit();
  parent.window.status="Administrator Submiting Report";
  //-------- End Page
  d.writeln('</body></html>');

}

//------- Called to log out from the site
function LogOutClick()
{ 
  if (windowonline!=null)
  {
    windowonline.close("/vtlebanonon/Home_E.html");
  }
  parent.navigate("home.html"); //home.html") ; AK @ 13/1/2005
}

function CloseAllWindows()
{
  if (windowonline!=null)
  {
    windowonline.close("/vtlebanonon/Home_E.html");
  }
}
