//global time of down the page in index.php just
function timer_vida(iranGMT){
	var GMT = -(new Date().getTimezoneOffset())/60;
	clockID = setTimeout("timer_vida("+GMT+","+iranGMT+")", 1000);
	var tDate = new Date();
	var tH = tDate.getHours();
	var tH2 = tH;
	if(tH <10) tH = "0"+ tH ;
	var tM = tDate.getMinutes();
	var tM2 = tM;
	if(tM <10) tM = "0"+ tM ;
	var tS = tDate.getSeconds();
	if(tS <10) tS = "0"+ tS ;
	var a=document.getElementById("mytime");
	var t=tH + ":"+ tM + ":"+ tS;
	GMToffset = iranGMT - GMT;
	minOffset = (((GMToffset * 10)%10)/10)*60;
	hourOffset = GMToffset - (((GMToffset * 10)%10)/10);
	tM2 = tM2 + minOffset;
	tH2 = tH2 + hourOffset;
	if(tM2>=60){
		tH2 = tH2 + 1;
		tM2 = tM2 - 60;
	}
	else if(tM2<=0){
		tH2 = tH2 - 1;
		tM2 = 60 + tM2;
	}
	if(tH2 <10) tH2 = "0"+ tH2 ;
	if(tM2 <10) tM2 = "0"+ tM2 ;
	var t2=tH2 + ":"+ tM2 + ":"+ tS;
	a.innerHTML=t;
	document.clock.face.value = t2;
}
  function GetDay(intDay){
    var DayArray = new Array("Sunday", "Monday", "Tuesday", "Wednesday", 
                         "Thursday", "Friday", "Saturday")
    return DayArray[intDay]
    }

  function GetMonth(intMonth){
    var MonthArray = new Array("January", "February", "March",
                               "April", "May", "June",
                               "July", "August", "September",
                               "October", "November", "December") 
    return MonthArray[intMonth] 	  	 
    }
  function getDateStrWithDOW(){
    var today = new Date()
    var year = today.getYear()
    if(year<1000) year+=1900
    var todayStr = GetDay(today.getDay()) + ", "
    todayStr += GetMonth(today.getMonth()) + " " + today.getDate()
    todayStr += ", " + year
    return todayStr
    }

function calendar(events,evDesc,holidays){
<!-- Begin
monthnames = new Array(
	"January",
	"Februrary",
	"March",
	"April",
	"May",
	"June",
	"July",
	"August",
	"September",
	"October",
	"November",
	"Decemeber");
var linkcount=0;
function addlink(month, day, href) {
	var entry = new Array(3);
	entry[0] = month;
	entry[1] = day;
	entry[2] = href;
	this[linkcount++] = entry;
}
Array.prototype.addlink = addlink;
linkdays = new Array();
monthdays = new Array(12);
monthdays[0]=31;
monthdays[1]=28;
monthdays[2]=31;
monthdays[3]=30;
monthdays[4]=31;
monthdays[5]=30;
monthdays[6]=31;
monthdays[7]=31;
monthdays[8]=30;
monthdays[9]=31;
monthdays[10]=30;
monthdays[11]=31;
todayDate=new Date();
thisday=todayDate.getDay();
thismonth=todayDate.getMonth();
thisdate=todayDate.getDate();
thisyear=todayDate.getYear();
thisyear = thisyear % 100;
thisyear = ((thisyear < 50) ? (2000 + thisyear) : (1900 + thisyear));
if (((thisyear % 4 == 0) 
		&& !(thisyear % 100 == 0))
		||(thisyear % 400 == 0)) 
	monthdays[1]++;
startspaces=thisdate;
while (startspaces > 7) startspaces-=7;
startspaces = thisday - startspaces + 1;
if (startspaces < 0) startspaces+=7;
document.write("<table border=1 bgcolor=white width=300px");
document.write("bordercolor=black><font color=black>");
/*document.write("<tr><td colspan=7><center><strong>" 
+ monthnames[thismonth] + " " + thisyear 
+ "</strong></center></font></td></tr>");*/
document.write("<tr>");
document.write("<td align=center bgcolor=\"#f1f1f1\">Su</td>");
document.write("<td align=center bgcolor=\"#f1f1f1\">M</td>");
document.write("<td align=center bgcolor=\"#f1f1f1\">Tu</td>");
document.write("<td align=center bgcolor=\"#f1f1f1\">W</td>");
document.write("<td align=center bgcolor=\"#f1f1f1\">Th</td>");
document.write("<td align=center bgcolor=\"#f1f1f1\">F</td>");
document.write("<td align=center bgcolor=\"#f1f1f1\">Sa</td>"); 
document.write("</tr>");
document.write("<tr>");
for (s=0;s<startspaces;s++) {
	document.write("<td> </td>");
}
count=1;
var eventcount=0;

while (count <= monthdays[thismonth]) {
	for (b = startspaces;b<7;b++) {
		linktrue=false;
		document.write("<td align=center ");
		if (count==thisdate && b==5) {
			document.write(" style=\"color: #FF0000\" ");
			if (count==events[eventcount]){
				document.write(" background=\"images/today-event.gif\"");
				eventcount=eventcount+1;
				linktrue=true;
			}else 
				document.write(" background=\"images/today.gif\"");
		}else	if (count==thisdate){
			if (count==events[eventcount]){
				document.write(" background=\"images/today-event.gif\"");
				eventcount=eventcount+1;
				linktrue=true;
			}else 
				document.write(" background=\"images/today.gif\"");
		}else	if (b==5){
			if (count==events[eventcount]){
				document.write(" style=\"color: #FF0000\" bgcolor=\"#CCCCCC\"");
				eventcount=eventcount+1;
				linktrue=true;
			}else 
				document.write(" style=\"color: #FF0000\" ");
		}else if (count==events[eventcount]){
				document.write(" bgcolor=\"#CCCCCC\"");
				eventcount=eventcount+1;
				linktrue=true;
		}
		document.write(">");
		if (linktrue){
			document.write("<strong>");
			document.write("<a href=\"news/news.php\" style=\"text-decoration:none\" onmouseout=\"popUp(event,'t"+evDesc[eventcount-1]+"')\" onmouseover=\"popUp(event,'t"+evDesc[eventcount-1]+"')\" ><font color=\"#000000\">");
		}
		/*for (c=0;c<linkdays.length;c++) {
			if (linkdays[c] != null) {
				if ((linkdays[c][0]==thismonth + 1) && (linkdays[c][1]==count)) {
					document.write("<a href=\"" + linkdays[c][2] + "\">");
					linktrue=true;
				}
			}
		}*/
		if (count <= monthdays[thismonth]) {
			document.write(count);
		}
		else {
			document.write(" ");
		}
		if (linktrue)
			document.write("</font></a></strong>");
		document.write("</td>");
		count++;
	}
	document.write("</tr>");
	document.write("<tr>");
	startspaces=0;
}
document.write("</table></p>");
// End -->
}

function clcSize(ftscid, isRes) {
				var seltext = ''; var i=0; var j=0; var isIE = 0;
				var ftsEl = document.getElementById('fts_'+ftscid);
				var fts2El = document.getElementById('fts2_'+ftscid);
				ftsEl.style.display='none';
				fts2El.style.display='none';
				if (window.getSelection) seltext = window.getSelection().toString();
				else if (document.selection && document.selection.createRange) { var range = document.selection.createRange(); seltext = range.text; isIE = 1; }
				if (seltext == '') return;
				seltext = seltext.replace(/http\:/g,' ').replace(/\r/g,'').replace(/\n/g,"\r\n");
				seltext = seltext.replace(/\s/g,' ').replace(/  {1,}/g,' ').replace(/ $|^ /g,'');
				seltext = seltext.replace(/\s/g,"\r\n");
				seltext = seltext.toLowerCase();
				var tmparr = seltext.split("\r\n"); var line = '';
			    var rsRegex = /^.*rapidshare\.(com|de)\/files\/([0-9]+)\/.*$/;
                if (!isRes) rsRegex = /^([0-9]{2})\/.+$/;
				var out = new Array();
				for (i=0, j=0; i<tmparr.length; i++) {
					line = tmparr[i];
					if (line.match(rsRegex)) {
					    if (isRes) line = line.replace(rsRegex, '$2'); else line = line.replace(rsRegex, '$1');	out[j] = line; ++j;
					}
				}
				if (j==0) return;
				var total = j; var totSize = 0.0; var tmpId;
				ftsEl.style.display='';
				fts2El.style.display='';
				while (j>0) {
					--j;
					if (tmpId = document.getElementById('rs' + out[j])) {
						if (isIE) totSize += parseFloat(tmpId.value.replace(' MB', ''));
						else totSize += +tmpId.value.replace(' MB', '');
					}
				}
				//var outText = '<table>';
				//outText += '<tr><td class="ft_sel">Selection:</td><td>' + (total.toString()) + ' file(s)</td></tr>';
				//outText += '<tr><td></td><td>';
				ftsEl.innerHTML = 'Selected:';
				var outText = total.toString() + ' file(s)<br />';
				if (totSize < 1000) { totSize = Math.round(totSize*10)/10; outText += totSize.toString() + ' MB'; }
				else { totSize = Math.round((totSize/1024)*100)/100; outText += totSize.toString() + ' GB'; }
				//outText += '</td></tr></table>';
				fts2El.innerHTML = outText;
}
