var strBuyerURL = "http://www.collectivepoint.com/AIMChatBuyer/"

function getexpirydate(nodays)
{
	var UTCstring;
	Today = new Date();
	nomilli = Date.parse(Today);
	Today.setTime(nomilli + nodays * 24 * 60 * 60 * 1000);
	UTCstring = Today.toUTCString();
	return UTCstring;
}

function setCookie(name,value,duration)
{
	if (document.iscookiesenable == 'false') return;
	
	document.cookie=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
}

function getCookie(cookiename)
{
	var cookiestring=""+document.cookie;
	var index1=cookiestring.indexOf(cookiename);
	
	try
	{
		if (document.iscookiesenable == 'false') 
			return "";
		
		if (index1==-1 || cookiename=="")
			return "";

		var index2=cookiestring.indexOf(';',index1);

		if (index2==-1)
			index2=cookiestring.length;

		if( cookiestring.substring( index1+cookiename.length, index1+cookiename.length+1 ) != "=")
			return "";
				
		return unescape( cookiestring.substring( index1+cookiename.length+1, index2 ) );
	}
	catch(e)
	{}
}

function setValuesForRegisterPage()
{
	document.UserFName = ( getCookie( 'AutoIM_UserFirstName' )	== null )? "" : getCookie( 'AutoIM_UserFirstName'	);
	document.UserMName = ( getCookie( 'AutoIM_UserMiddleName' ) == null )? "" : getCookie( 'AutoIM_UserMiddleName'	);
	document.UserLName = ( getCookie( 'AutoIM_UserLastName' )	== null )? "" : getCookie( 'AutoIM_UserLastName'	);
	document.UserEmail = ( getCookie( 'AutoIM_UserEmail' )		== null )? "" : getCookie( 'AutoIM_UserEmail'		);
	//document.UserQuestion = ( getCookie( 'AutoIM_UserQuestion' ) == null )? "" : getCookie( 'AutoIM_UserQuestion' );
}

function getIsUserReVisitor()
{
	var strReVisitor = getCookie( 'AutoIM_ReVisitor' );

	try
	{
		if( strReVisitor != null && strReVisitor != "" )
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	catch(e)
	{}
}

function setReVisitor()
{
	setCookie( 'AutoIM_ReVisitor', 'true', 365 );
}
function getLinks()
{
	try{
		sendRequest( strBuyerURL + "IconGen.aspx?LocationID=" + document.LocationID
				+ "&CompanyID=" + document.CompanyID + "&TeamID=" + document.TeamID 
				+ "&SettingID=" + document.SettingID + "&ReVisitor=" + getIsUserReVisitor(),
				1, 1);
	}
	catch(e){}
	/*try
	{
		head=document.getElementsByTagName('head').item(0);
		script=document.createElement('script');
		script.src = strBuyerURL + "IconGen.aspx?LocationID=" + document.LocationID + "&CompanyID=" + document.CompanyID + "&TeamID=" + document.TeamID + "&SettingID=" + document.SettingID + "&ReVisitor=" + getIsUserReVisitor()
		script.type = 'text/javascript';
		script.defer = true;
		script.id = 'Icons'
		void(head.appendChild(script));
	}
	catch(e)
	{}*/
}