
var const_key_cookie_name = "sga.member.key";

function showsectionifchecked(objType, displayID, hideID)
{
	showsectionifchecked_internal(objType, displayID, true);
	if(typeof(hideID)!="undefined")
		showsectionifchecked_internal(objType, hideID, false);
}

function hidesectionifchecked(objType, displayID)
{
	showsectionifchecked_internal(objType, displayID, false);
}

function showsectionifchecked_internal(objType, displayID, show)
{
	if(isArray(displayID)) 
	{
		var i;
		for (i=0;i<displayID.length;i++)
		{
			var element=document.getElementById(displayID[i]);
			element.style.display=(objType.checked==show)?'block':'none';
			if(typeof(element.type)!="undefined" && element.type=="text" && objType.checked!=show)
				element.value="";
		}
	} else {
		document.getElementById(displayID).style.display=(objType.checked==show)?'block':'none';
	}
}

function isArray(obj) 
{
   if (obj.constructor.toString().indexOf("Array") == -1)
      return false;
   else
      return true;
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		var c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}

function include(filename)
{
	var head = document.getElementsByTagName('head')[0];
	
	script = document.createElement('script');
	script.src = filename;
	script.type = 'text/javascript';
	
	head.appendChild(script)
}

function includeExternal(filename)
{
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	var head = document.getElementsByTagName('head')[0];
	
	script = document.createElement('script');
	script.src = gaJsHost+filename;
	script.type = 'text/javascript';
	
	head.appendChild(script)
}

