/**
"this script is use only for panjatanpak.com"
author syed zeeshan ali aka shaggy
copyrigths 2007-http://www.shaggy.co.nr/
 */
function HijriDate()
        {
            var odate = new Date();
            return (String(odate.getDate()) + " " + (NameFromMonth(parseInt(String(odate.getMonth()+1)))) +  ", " + String(odate.getYear()) + " (" + GregToIsl(odate.getMonth()+1,odate.getDate(), odate.getYear()));
        }

	    function intPart(floatNum)
	    {
		    if (floatNum< -0.0000001)
		    {
		     return Math.ceil(floatNum-0.0000001)
		    }
		    return Math.floor(floatNum+0.0000001)	
	    }

	    function GregToIsl(m,d,y) 
	    {
    		
		    if ((y>1582)||((y==1582)&&(m>10))||((y==1582)&&(m==10)&&(d>14))) 
			    {
			    jd=intPart((1461*(y+4800+intPart((m-14)/12)))/4)+intPart((367*(m-2-12*(intPart((m-14)/12))))/12)-
			    intPart( (3* (intPart(  (y+4900+    intPart( (m-14)/12)     )/100)    )   ) /4)+d-32075
			    }
			    else
			    {
			    jd = 367*y-intPart((7*(y+5001+intPart((m-9)/7)))/4)+intPart((275*m)/9)+d+1729777
			    }
		    l=jd-1948440+10632
		    n=intPart((l-1)/10631)
		    l=l-10631*n+354
		    v=(intPart((10985-l)/5316))*(intPart((50*l)/17719))+(intPart(l/5670))*(intPart((43*l)/15238))
		    l=l-(intPart((30-v)/15))*(intPart((17719*v)/50))-(intPart(v/16))*(intPart((15238*v)/43))+29
		    m=intPart((24*l)/709)
		    d=l-intPart((709*m)/24)
		    y=30*n+v-30

		    return(String(d-1) + " " + NameFromMonthH(parseInt(m)) + ", " +  y + " A.H.)")
		    //return(String(30) + " " + NameFromMonthH(parseInt(m-1)) + ", " +  y + " A.H.)&nbsp")

	    }


	    function NameFromMonthH(iMonth)
	    {
		    if (iMonth==1) {return "Muharram"}
		    if (iMonth==2) {return "Safar"}
		    if (iMonth==3) {return "Rabil'al Awwal"}
		    if (iMonth==4) {return "Rabil'al Athani"}
		    if (iMonth==5) {return "Jamaada'al Ula"}
		    if (iMonth==6) {return "Jamaada'al Athani"}
		    if (iMonth==7) {return "Rajab"}
		    if (iMonth==8) {return "Sha'ban"}
		    if (iMonth==9) {return "Ramadhan"}
		    if (iMonth==10) {return "Shawaal"}
		    if (iMonth==11) {return "Dhu l Qa'dah"}
		    if (iMonth==12) {return "Dhu al Hajjah"}

	    }


	    function NameFromMonth(iMonth)
	    {

		    if (iMonth==1) {return "January"}
		    if (iMonth==2) {return "February"}
		    if (iMonth==3) {return "March"}
		    if (iMonth==4) {return "April"}
		    if (iMonth==5) {return "May"}
		    if (iMonth==6) {return "June"}
		    if (iMonth==7) {return "July"}
		    if (iMonth==8) {return "August"}
		    if (iMonth==9) {return "September"}
		    if (iMonth==10) {return "October"}
		    if (iMonth==11) {return "November"}
		    if (iMonth==12) {return "December"}

	    }
		
/*zakat cal*/
function zakat()
{
var cash,shares,gold_silverValue,goldWeight,silverWeight,goldPrice,silverPrice, year;
var gold,silver;

cash = parseInt(document.calForm.cash.value);
shares= parseInt(document.calForm.shares.value);
gold_silverValue= parseInt(document.calForm.gold_silverValue.value);
goldWeight= parseInt(document.calForm.goldWeight.value);
goldPrice= parseInt(document.calForm.goldPrice.value);
silverWeight= parseInt(document.calForm.silverWeight.value);
silverPrice = parseInt(document.calForm.silverPrice.value);

if (goldWeight <= 2) 
	 gold = 0; 
else 
	 gold = goldWeight * goldPrice; 

if (silverWeight <= 2) silver=0;
	else silver = silverWeight * silverPrice;

total = cash + shares + gold_silverValue +  gold + silver;
total=total * 0.025;

alert( "Your Total estimated Zakat is " + total);

return false;
}
/*form validate*/
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
// this is open browser new window with 600 X 500
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
