

function CreateClock(strContainerID,strCurrentServerTime,strServerTimezone,strLocationName,strLocationTimezone)
{
    
    
    //Timezones are given in format ex: '-0300' and '+0100' so we will split it into something of use to us
    $strAddOrSubstractServerTime=strServerTimezone.substring(0,1);
    $strServerHourShiftBy=strServerTimezone.substring(1,3);
    
    
    
    if ($strAddOrSubstractServerTime=='+')
        $iBaseServerTimeShift=-Number($strServerHourShiftBy);
    else
        $iBaseServerTimeShift=Number($strServerHourShiftBy);
    
    $strAddOrSubstractLocationTime=strLocationTimezone.substring(0,1);
    $strLocationHourShiftBy=strLocationTimezone.substring(1,3);
    
    if ($strAddOrSubstractLocationTime=='-')
        $iLocationTimeShift=-Number($strLocationHourShiftBy);
    else
        $iLocationTimeShift=Number($strLocationHourShiftBy);
    
    
    
    this.iSecAngle=0;
    this.iMinAngle=0;
    this.iHourAngle=0;
    
    this.Initialize = function()
    {
        arrServerTime=strCurrentServerTime.split(':');
        iServerHour=arrServerTime[0];
        iServerMin=arrServerTime[1];
        iServerSec=arrServerTime[2];
        
        iLocationHour=Number(iServerHour)+Number($iBaseServerTimeShift)+Number($iLocationTimeShift);
        
        $("#"+strContainerID).html('<img class="SecArm" id="SecArmFor'+strContainerID+'" src="shared/images/sec_arm.png"/><img class="MinArm" id="MinArmFor'+strContainerID+'" src="shared/images/min_arm.png"/><img class="HourArm" id="HourArmFor'+strContainerID+'" src="shared/images/hour_arm.png"/><div class="ClockLocation">'+strLocationName+'</div>');
        
         
        this.iSecAngle=iServerSec*6;
         $('#SecArmFor'+strContainerID).rotate(this.iSecAngle);
     
        this.iMinAngle=Number(iServerMin*6)+Number(iServerSec*0.1);
        $('#MinArmFor'+strContainerID).rotate(this.iMinAngle);
        
        this.iHourAngle=Number(iLocationHour*30)+Number(iServerMin*0.5);
        $('#HourArmFor'+strContainerID).rotate(this.iHourAngle);
        
        var objClock=this;
        
        setInterval( function(){
            objClock.RotateSecArm();
        }, 100);
        
         setInterval( function(){
            objClock.RotateMinAndHourArm();
        }, 5000);
        
        
    }
    
    this.RotateSecArm = function()
    {
        $('#SecArmFor'+strContainerID).rotate({
            angle:this.iSecAngle,
            duration: 100
        });
        
        this.iSecAngle+=0.6;
    }
    
    this.RotateMinAndHourArm = function()
    {
        $('#MinArmFor'+strContainerID).rotate(this.iMinAngle);
        this.iMinAngle+=(6/60)*5;
        
        $('#HourArmFor'+strContainerID).rotate(this.iHourAngle);
        this.iHourAngle+=(0.5/60)*5;
    }
    
    this.Initialize();
    
    return true;
}



