	var fixd;

	function isGregLeapYear(year)
	{
		return year%4 == 0 && year%100 != 0 || year%400 == 0;
	}

	function gregToFixed(year, month, day)
	{
		var a = Math.floor((year - 1) / 4);
		var b = Math.floor((year - 1) / 100);
		var c = Math.floor((year - 1) / 400);
		var d = Math.floor((367 * month - 362) / 12);

		if (month <= 2)
			e = 0;
		else if (month > 2 && isGregLeapYear(year))
			e = -1;
		else
			e = -2;

		return 1 - 1 + 365 * (year - 1) + a - b + c + d + e + day;
	}

	function Hijri(year, month, day)
	{
		this.year = year;
		this.month = month;
		this.day = day;
		this.toFixed = hijriToFixed;
		this.toString = hijriToString;
	}

	function hijriToFixed()
	{
		return this.day + Math.ceil(29.5 * (this.month - 1)) + (this.year - 1) * 354 +
 			Math.floor((3 + 11 * this.year) / 30) + 227015 - 1;
	}

	function hijriToString()
	{
		var months = new Array("Muharram","Safar","Rabiul Awwal","Rabiul Akhir","Jamadil Awwal","Jamadil Akhir","Rajab","Sha'ban","Ramadhan","Shawwal","Dhulka'edah","Dhulhijjah");
  	return this.day + " " + months[this.month - 1]+ " " + this.year;
	}

	function fixedToHijri(f)
	{
  	var i=new Hijri(1100, 1, 1);
   	i.year = Math.floor((30 * (f - 227015) + 10646) / 10631);
   	var i2=new Hijri(i.year, 1, 1);
   	var m = Math.ceil((f - 29 - i2.toFixed()) / 29.5) + 1 ; // Add one here whenever we wish to move to next month.
   	i.month = Math.min(m, 12);
   	i2.year = i.year;
	 	i2.month = i.month;
	 	i2.day = 1;
   	i.day = f - i2.toFixed() + 1;  // Add one here whenever we wish to increment a day in hijri.
                   if ( i.day == 31 && i.month == 12) {i.day = 1; i.month=1; i.year=i.year+1;}
                   if ( i.day == 31 && i.month < 12) {i.day = 1; i.month=i.month+1;}
   	return i;
	}


//	document.write(weekday[dow]);

// var right_now = new Date();
// document.write(" Time = ");
// var right_hours=right_now.getHours();
// if (right_hours > 12) right_hours = right_hours - 12; 
// document.write(right_hours);
// document.write(":");

// var right_min=right_now.getMinutes();
// if (right_min < 10)
//  document.write("0");
// document.write(right_min);
// document.write(" ");

// var ampm=" A.M.";
// if (right_now.getHours() > 12)
// ampm=" P.M.";
// document.write(ampm);

