function SetCookie (name, value) {
         var argv = SetCookie.arguments;
         var argc = SetCookie.arguments.length;
         var expires = (argc > 2) ? argv[2] : null;
         document.cookie = name + "=" + escape (value) + "; expires=" + expires.toGMTString() +"; path=/" + "; domain=www.iraniha.com";
}
function GetCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function doChange(theVar)
{
	document.bgColor=theVar;

	var expdate = new Date ();
	expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 365));

	SetCookie ("bgColor", theVar, expdate);
}

function doAlign(theVar)
{
	mt.align=theVar;

	
	var expdate = new Date ();
	expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 365));

	SetCookie ("position", theVar, expdate);
	
	init();
}

// Retrieve Cookie
var bgColor=GetCookie("bgColor");
var align=GetCookie("position");
// Create New Expirey Date
var expdate = new Date ();
expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
//  Check Cookie if NULL Default Value else Set to chosen value
if (bgColor== null) {
             var bgColor = "#ffffff";
             SetCookie ("bgColor", bgColor, expdate);
}else{
             SetCookie ("bgColor", bgColor, expdate);
		 	 document.bgColor=bgColor;
}

if (align==null) {
			var align = "center";
            SetCookie ("position", align, expdate);
}
else
	{
			mt.align=align;
			SetCookie ("position", align, expdate);
	}