/* COOKIE Handling */
function createCookie(name,value,days) {
			if (days) {
				var date = new Date();
				date.setTime(date.getTime()+(days*24*60*60*1000));
				var expires = "; expires="+date.toGMTString();
			}
			else var expires = "";
			document.cookie = name+"="+value+expires+"; path=/";
}

function checkKey(theReferrer)
{
	keyValue = '0';
	/* check if referrer is credilogros */
	if (theReferrer != '')
	{
		/* we add 1+ to the array values
		0 _ otro
		1 _ credilogros
		2 _ prestamo
		3 _ credito
		*/
		var keyArray=new Array("credilogros","prestamo","credito");
		var z;

		for (z in keyArray)
		{
			if (theReferrer.indexOf(keyArray[z]) > 1)
			{
				keyValue = parseInt(z) +1;

				return keyValue;
			}
		}
	}
	return keyValue;

}


function checkReferrer(theReferrer)
{
	cookieValue = '0'; 
	/* check if referrer is credilogros */
	if (theReferrer != '')
	{
		/* we add 2+ to the array values
		1 _ directo
		2 _ google.com.ar
		3 _ google.com
		4 _ ar.search.yahoo.com
		5 _ yahoo.com
		6 _ live.com
		7 _ search.msn.com
		8 _ otro
		*/
		var searchArray=new Array("google.com.ar","google.com","ar.search.yahoo.com", "yahoo.com", "live.com", "search.msn.com", ".");
		var y;

		for (y in searchArray)
		{
			if (theReferrer.indexOf(searchArray[y]) > 1)
			{
				searchValue = parseInt(y) + 2;
				cookieValue = checkKey(theReferrer).toString() + searchValue.toString();
				return cookieValue;
			}
		}

	}
	return cookieValue;
}
