﻿// JScript File

//////////////////////////////// START CLOCK SCRIPT ///////////////////////////////
var timerID ;

function tzone(tz, os, ds)
{
	this.ct = new Date(0) ;		// datetime
	this.tz = tz ;		// code
	this.os = os ;		// GMT offset
	this.ds = ds ;		// has daylight savings
}

function UpdateClocks()
{
	// www.timeanddate.com/worldclock
	var ct = new Array(
		new tzone('New York: ', -5, 1),
		new tzone('London: ', +1, 1),
		new tzone('Dubai: ', +4, 0)
	) ;

	var dt = new Date() ;	// [GMT] time according to machine clock

	var startDST = new Date(dt.getFullYear(), 3, 1) ;

	while (startDST.getDay() != 0)
		startDST.setDate(startDST.getDate() + 1) ;

	var endDST = new Date(dt.getFullYear(), 9, 31) ;

	while (endDST.getDay() != 0)
		endDST.setDate(endDST.getDate() - 1) ;

	var ds_active ;		// DS currently active

	if (startDST < dt && dt < endDST)
		ds_active = 1 ;
	else
		ds_active = 0 ;

	// Adjust each clock offset if that clock has DS and in DS.

	for(n=0 ; n<ct.length ; n++)
		if (ct[n].ds == 1 && ds_active == 1) ct[n].os++ ;

	// compensate time zones

	gmdt = new Date() ;

	for (n=0 ; n<ct.length ; n++)
		ct[n].ct = new Date(gmdt.getTime() + ct[n].os * 3600 * 1000) ;

	document.getElementById("Clock0").innerHTML = ct[0].tz + ClockString(ct[0].ct) ;
	
	document.getElementById("Clock1").innerHTML = ct[1].tz + ClockString(ct[1].ct) ;
	
	document.getElementById("Clock2").innerHTML = ct[2].tz + ClockString(ct[2].ct) ;

	timerID = window.setTimeout("UpdateClocks()", 1001) ;
}

function ClockString(dt)
{
	var stemp, ampm ;
	var dt_hour = dt.getUTCHours() ;
	var dt_minute = dt.getUTCMinutes() ;
	var dt_second = dt.getUTCSeconds() ;

	if (0 <= dt_hour && dt_hour < 12)
	{
		ampm = 'AM' ;
		if (dt_hour == 0) 
		    dt_hour = 12 ;
	} else {
		ampm = 'PM' ;
		dt_hour = dt_hour - 12 ;
		if (dt_hour == 0) 
		    dt_hour = 12 ;
	}

	if (dt_minute < 10)
		dt_minute = '0' + dt_minute ;

	if (dt_second < 10)
		dt_second = '0' + dt_second ;

	stemp = dt_hour + ":" + dt_minute + ":" + dt_second + ' ' + ampm ;

	return stemp ;
}

//////////////////////////////// END CLOCK SCRIPT //////////////////////////////

// Set the horizontal and vertical position for the popup
		PositionX = 100;
		PositionY = 100;
		// Set these value approximately 20 pixels greater than the
		// size of the largest image to be used (needed for Netscape)

		defaultWidth  = 500;
		defaultHeight = 500;
		// Set autoclose true to have the window close automatically
		// Set autoclose false to allow multiple popup windows

		var AutoClose = true;

		// Do not edit below this line...
		// ================================
			if (parseInt(navigator.appVersion.charAt(0))>=4)
			{
				var isNN=(navigator.appName=="Netscape")?1:0;
				var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
			}
			
			var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
			var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
			
			function popImage(imageURL,imageTitle)
			{
				if (isNN)
					imgWin=window.open('about:blank','',optNN);
				if (isIE)
					imgWin=window.open('about:blank','',optIE);
				with (imgWin.document)
				{
					writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
					writeln('<sc'+'ript>');
					writeln('var isNN,isIE;');
					writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
					writeln('isNN=(navigator.appName=="Netscape")?1:0;');
					writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
					writeln('function reSizeToImage(){');
					writeln('if (isIE){');
					writeln('window.resizeTo(100,100);');
					writeln('width=100-(document.body.clientWidth-document.images[0].width);');
					writeln('height=100-(document.body.clientHeight-document.images[0].height);');
					writeln('window.resizeTo(width,height);}');
					writeln('if (isNN){');       
					writeln('window.innerWidth=document.images["George"].width;');
					writeln('window.innerHeight=document.images["George"].height;}}');
					writeln('function doTitle(){document.title="'+imageTitle+'"; if(document.title == "") document.title="Road Safety & Traffic Management 2006";}');
					writeln('</sc'+'ript>');
					if (!AutoClose) 
						writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
					else 
						writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
					
					writeln('<img name="George" src="'+imageURL+'" style="display:block"></body></html>');
					close();		
				}
			}
			
  function Id(e) { return document.getElementById(e); }
  
  function launchIEP(e) 
  {
	e = Id(e);
	if(e.options[e.options.selectedIndex].value!="")
		window.open(e.options[e.options.selectedIndex].value);
	return false;
  }
  
  function checkPayment(sender, args)
  {
    var elem = document.getElementsByName("ctl00$BodyPlaceHolder$RegisterForm$Payment");
    if(!elem[0].checked && !elem[1].checked)
        args.IsValid = false;
    else if(elem[1].checked && args.Value == "")
        args.IsValid = false;
    else
        args.IsValid = true;
  }