// JavaScript by Shaahin Mohammadi - Shaahin@mac.com
// © Feb. 21 2001, Neda Network & Shaahin Mohammadi
// -------------------------------------------------------------
// --
// Cookie Monster!
// --
function SetCookie (name, value){
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : 'www.neda.net.ir';
  var secure = (argc > 5) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
  return false;}

function cookieset(){
var now = new Date();
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
SetCookie('UserName', document.email.User.value, now);
return(0);}

function getCookieVal (offset){
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1) endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));}

function GetCookie (name){
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen){
	var j = i + alen;
	 if (document.cookie.substring(i, j) == arg)
	return getCookieVal (j);
	 i = document.cookie.indexOf(" ", i) + 1;
	if (i == 0) break; 
	 }
  return null;}

function DisplayName(){
   if(GetCookie('UserName') != null){
	document.email.User.value = GetCookie('UserName');}
   }


// Date & Time

  var dayarray   = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
  var montharray = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
 
  function getClockDate() {
	var d       = new Date();
	var year    = d.getYear();
	var day     = d.getDay();
	var month   = d.getMonth();
	var numday  = d.getDate();
	var hours   = d.getHours();
	var minutes = d.getMinutes();
	var seconds = d.getSeconds();
	var dn;
	if (year < 2000) { year = "19" + year; }
	if (hours > 12){ dn = "PM"; hours = hours - 12; } else { dn = "AM"; }
	if (hours == 0) { hours = 12; }
	if (minutes <= 9) { minutes = "0" + minutes; }
	if (seconds <= 9) { seconds = "0" + seconds; }
	document.all["dateObject"].innerHTML = dayarray[day] + ",&nbsp;" + montharray[month] + "&nbsp;" + numday + ",&nbsp;" + year;
	document.all["timeObject"].innerHTML = "&nbsp;&nbsp;" + hours + ":" + minutes + ":" + seconds + "&nbsp;" + dn;
	document.all["dateObject2"].innerHTML = dayarray[day] + ",&nbsp;" + montharray[month] + "&nbsp;" + numday + ",&nbsp;" + year;
	document.all["timeObject2"].innerHTML = hours + ":" + minutes + ":" + seconds + "&nbsp;" + dn;
 
}
  
function init() {
    getClockDate();
    setInterval("getClockDate()", 1000);  
}

// Add To Favorites

function AddToFavorites() {
window.external.AddFavorite('http://www.neda.net.ir/downloads/index.html', 'Neda Network - Downloads')
}