// JavaScript Document

function Now()
{
	var Result = new Date().toString();
	var arrNOW = Result.split("UTC")
	Result = arrNOW[0];
	return Result;
}

function setCookie(cookieName, cookieValue, expireDate)
{
/* Pass in three strings - the name of the cookie, the value, and the
expire date.
Pass in a "" empty string for expireDate to set a session cookie
(no expires date).
Pass in any other date for expire as a number of days to be added
to today's date. */

	if (expireDate == "")
	{
		var expires = "";
	}
	else
	{
		var expires = new Date();
		expires.setDate(expires.getDate() + expireDate);
		expires = expires.toGMTString();
	}
	//alert("expires-setCookie="+expires);
	//document.cookie = cookieName+"="+cookieValue+";expires="+expires+";path=/";
	document.cookie = cookieName+"="+cookieValue+";expires="+expires;
}

function setCookieMobile(cookieName, cookieValue, expireDate)
{
/* Pass in three strings - the name of the cookie, the value, and the
expire date.
Pass in a "" empty string for expireDate to set a session cookie
(no expires date).
Pass in any other date for expire as a number of days to be added
to today's date. */

	if (expireDate == "")
	{
		var expires = "";
	}
	else
	{
		var expires = new Date();
		expires.setDate(expires.getDate() + expireDate);
		expires = expires.toGMTString();
	}
	//alert("expires-setCookie="+expires);
	document.cookie = cookieName+"="+cookieValue+";expires="+expires+";path=/";
	//document.cookie = cookieName+"="+cookieValue+";expires="+expires;
}

function removeCookie(cookieName)
{
/* Pass in the name of the cookie as a string and it will be removed.*/

	var expires=Now();
	//expires = expires.toGMTString();
	//alert("expires-removeCookie=" +expires);
	document.cookie = cookieName+"="+cookieName+";expires="+expires;
}

function getCookie (cookieName)
{
cookieValue = ""
if (document.cookie.indexOf(cookieName) == -1)
{
// there is no cookie by this name for this user
return cookieValue;
}
else
{
// get the beginning index of the cookie by looking for the cookie
//name
cookieStart = document.cookie.indexOf(cookieName);
// get the beginning index of the cookie value by looking for the
//equal sign after the name
cookieValStart = (document.cookie.indexOf("=", cookieStart) + 1);
// get the end index of the cookie value by looking for the semi-
//colon after the value
cookieValEnd = document.cookie.indexOf(";", cookieStart);
// if no semi-colon, then use the whole length
if (cookieValEnd == -1)
{
cookieValEnd = document.cookie.length
}
// use substring to get the text between the two indices and that
//is the value of the cookie
cookieValue = document.cookie.substring(cookieValStart,cookieValEnd);

return cookieValue;
}
}

function detectCookies()
{
/* function returns true if cookies are enables, false if not */
setCookie("test", "test", "");
tmp = getCookie("test")
if (tmp != "test")
{
return false;
}
else
{
return true;
}
}
function writecookies(namepage)
{  
    //alert("writecookies");
	//alert(namepage);
	var mycookieparent=setCookie('nameparent',namepage ,'');
	var mycookiechild=setCookie('namechild','none' ,'');
}

function testlogin(namepage)
{ 
 	var mylogin=getCookie('loggedin');
	//alert("namepage:" +namepage);
   //alert("testlogin=" + mylogin);
 if (mylogin=="true" && mylogin!==""  && mylogin!==" ")
 
  {
    
	 document.write("<a href='http://www.authpro.com/cgi-bin/auth.fcgi?user=marmur&action=logout' class='top'>Logout</a>")
   
 
  }
   else
    {	
	  
		//document.write("<a href='login-form.html' class='top' onClick='writecookies(namepage);'>Login</a>");
		//document.write("<a href='#' class='top' onClick='writecookies(namepage);'>Login</a>");
		var a=1;
		//var a=eval(a);
		var a="dana";
		document.write('<a href="login-form.html" class="top" onClick="writecookies('+ "'"+namepage+"'"+ ');">Login</a>');
		
		//alert("after login"); 
		//var mychild=getCookie('namechild');
		
  	 }
   }
//window.onload = ActivateFlash 

function ActivateFlash() 
{ 
    var objects = document.getElementsByTagName("object"); 
    //alert(objects.length);
    for (var i = 0; i < objects.length-1; i++) 
    { 
      objects[i].outerHTML = objects[i].outerHTML; 
    } 
} 
