
var position,canvas, c, bg, t, h, m, s;


function start(){

    //var position ;
    //position = 0;
    position =  $("#header_info").position();

    var left_pos =  position.left+733;
    var top_pos = -84;
    //alert(position.left + " - " + $("#header_info").width() +" ** " + left_pos + " - " + top_pos);
	canvas = Raphael( left_pos+100, top_pos+100 , 200,200);

	//bg = canvas.image("http://www.cc-saverne.fr/sites/oceanide2010/_templates/oceanide/images/clock_cni.png", 32, 32, 138, 138);
   // bg = canvas.image("http://www.cc-saverne.fr/sites/oceanide2010/_templates/oceanide/images/clock_cni.png", 31, 30, 140, 140);

    // for hours
	h = canvas.path("M100 100L100 60");
	h.attr({stroke: "#000", "stroke-width": 5 });
	// for mins
	m = canvas.path("M100 100L100 45");
	m.attr({ stroke: "#000", "stroke-width": 3 });

	c = canvas.circle(left_pos, top_pos, 5);
	c.attr("fill", "#000000");

	setInterval("moveSec()",1000);
}

function moveSec()
{
	var date = new Date();
	var sec = date.getSeconds();
	var mins = date.getMinutes();
	m.rotate(6*mins, 100, 100);
	var hrs = date.getHours();
	h.rotate(30*hrs+(mins/3), 100, 100);
}

 draw_clock();
function draw_clock()
{

$(function(){
    // alert($.browser.version.substring(0,3));
    if(!$.browser.opera && ($.browser.mozilla && $.browser.version.substring(0,3) > 3.5 ) || ($.browser.msie && $.browser.version.substring(0,3) >= 8.0 ) )
    {
    	start();
    	$("#canvas img").click(function(){
    		bg.attr({src: $(this).attr("src")});
    	});
    	$("#hour").change(function(){
    		h.attr({stroke: $(this).val()});
    	});
    	$("#mins").change(function(){
    		m.attr({stroke: $(this).val()});
    	});
    	$("#secs").change(function(){
    		s.attr({stroke: $(this).val()});
    	});
    }else{
        $("#fmi2").html('<div style="padding-left:15px;padding-top:45px;font-weight:bold;font-size:16x;color:#E2490C;">'+ get_time() +'</div>');
    }
});
}

function get_time()
{
  Today = new Date;
  Heure = Today.getHours();
  Min = Today.getMinutes();
  Sec = Today.getSeconds();
  if (Min<10)
  Min = "0"+Min;
  if (Sec<10)
  Sec = "0"+Sec;
  return Heure + ":" + Min + ":" + Sec;
}




