function check_mail(email)
{
	reg_ex5=/^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$/;

	if(reg_ex5.test(email))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function check_notempty(field)
{
	if(field.replace(/ /g,'') == '')
	{
		return false;
	}
	else
	{
		return true;
	}
}

function check_date(day, month, year)
{
	if(year.length != 4) return false;
	
	if (month==4 || month==6 || month==9 || month==11)
	{
		daysmonth=30;
	}
	else if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)
	{
		daysmonth=31;
	}
	else if(month==2 && year%4==0 && year%100!=0 || year%400==0)
	{
		daysmonth=29;
	}
	else if(month==2 && year%4!=0 || year%100==0 && year%400!=0)
	{
		daysmonth=28;
	}
	
	if(day>=1 && day<=daysmonth && month>=1 && month<=12)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function set_cookie_conf(key, val)
{
	var expires = new Date();
	expires.setTime(expires.getTime() + (60 * 60 * 24 * 10000));
	document.cookie = key+"="+val+";expires="+expires.toGMTString()+";path=/;";
}

function get_cookie_conf(key)
{	
	var cookies = document.cookie.split(";");

	var matcher = new RegExp(key);
	
	for(i = 0; i < cookies.length; i++)
	{
		var cookiedata = cookies[i].split("=");
	
		if(matcher.test(cookiedata[0]) == true)
		{
			return cookiedata[1];			
		}
	}	
}

function createExternalLink()
{
	if(document.getElementById('imageurl').value != '')
	{
		document.getElementById('link').value = 'http://www.digitalpuzzle.net/play.php?img='+document.getElementById('imageurl').value;
	}
}
