// JavaScript Document --- PROKHAS WEB
// author: Mohamad Imran
// last updated: 17.09.2009 - 9:30 am.


var popUpWin=0;
//var width=30;

function popUpWindow(URLStr, left, top, width, height)

{

  if(popUpWin)

  {

    if(!popUpWin.closed) popUpWin.close();

  }

  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');


}





function popscr(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=no,resizable=yes,width=400,height=370,left = 800,top = 150');");
}





function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}






function fakecounter(){

//decrease/increase counter value (depending on perceived popularity of your site!)
var decrease_increase=-1

var counterdate=new Date()
var currenthits=counterdate.getTime().toString()
currenthits=parseInt(currenthits.substring(2,currenthits.length-4))+decrease_increase - 5000000

//document.write("You are visitor no <b>"+currenthits+"</b> to this site since its official launch on 13 July 2006.")
}
fakecounter()



function pop(){
	windowone=window.open("jobvacancy.html",'window','scrollbars=yes,statusbar=no,toolbar=no,personalbar=no,menubar=no,locationbar=yes,resizable=no,width=670,height=600,top=0,left=0');
	}











// ------------------------ function date in Masehi & Hijrah!
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("Muharam","Safar","Rabi'ul Awal","Rabiul Akhir","Jamadil Awal","Jamadil Akhir","Rejab","Sya'ban","Ramadhan","Syawal","Dzulka'edah","Dzulhijjah");
  	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;
   	
   	i.month = Math.min(m, 12);
   	i2.year = i.year;
	 	i2.month = i.month;
	 	i2.day = 1;
   	i.day = f - i2.toFixed() + 1;
   	return i;
}
	
	
	
	
	
var tod=new Date();
var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var monthname=new Array("Januari","Februari","Mac","April","Mei","Jun","Julai","Ogos","September","Oktober","November","Disember");

var y = tod.getFullYear();
var m = tod.getMonth();
	
var d = tod.getDate();
var dow = tod.getDay();
	
//--- start: added this line on 5 Okt 2005 sistem kira udah 2 Ramadhan, reverse 1 day
//	if (d > 1)
//		hijd = d - 1;
//--- end

	//document.write(weekday[dow] + " " + d + " " + monthname[m] + " " + y);
	

m++;
	
	//--- closed on 5 okt 2005, rujuk atas	
	//fixd=gregToFixed(y, m, hijd);

fixd=gregToFixed(y, m, d);
	
var h=new Hijri(1421, 11, 28);
h = fixedToHijri(fixd);










//----------------------------------- Running clock!

function updateClock ( )
{
  var currentTime = new Date ( );

  var currentHours = currentTime.getHours ( );
  var currentMinutes = currentTime.getMinutes ( );
  var currentSeconds = currentTime.getSeconds ( );

  // Pad the minutes and seconds with leading zeros, if required
  currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

  // Choose either "AM" or "PM" as appropriate
  var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

  // Convert the hours component to 12-hour format if needed
  currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

  // Convert an hours component of "0" to "12"
  currentHours = ( currentHours == 0 ) ? 12 : currentHours;

  // Compose the string for display
  var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;

  // Update the time display
  document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}


