<?php
if (file_exists("embedded/functions/site_functions.php"))
	{
	include_once("embedded/functions/site_functions.php");
	}
else
	{
include_once("../../embedded/functions/site_functions.php");
	}
if (isset($_GET["q"]) && !empty($_GET["q"]))
{
db_open();
$device_id=$_SESSION['device_id'];
$language=$_SESSION['language'];
if ($language==1)
	{
	$head1="Σφάλμα δεδομένων!";
	$head2="Επιτυχής!";
	$head3="Υπό χρήση!";
	$pattern="/[^_A-Za-zάΆέΈήΉίΊόΌύΎώΏΖζΧχΨψωΩβΒνΝμΜΛλΚκΞξΗηΓγΦφΔδΣσΑαςΕεΡρΤτΥυΘθΙιΟοπΠ0-9\' ']/";
	}
else
	{
	$head1="Invalid data!";
	$head2="Done!";
	$head3="Already in use!";
	$pattern="/[^_A-Za-z0-9\' ']/";
	}
$msg="";
$class="";
$q= strip_tags(htmlspecialchars(mysql_real_escape_string(trim($_GET["q"]))));
	if (preg_match($pattern, $q))
	{
	$msg="$head1";
	$class="invalid";
	}
	else
	{
	$a=check_availability($name=$q,$table="scenarios",$device_id);
	if ($a=="1")
		{
		$msg="$head2";
		$class="valid";
		}
	else
		{
		$msg="$head3";
		$class="invalid";
		}
		
	}
echo "<span class='$class'>$msg</span>";	
	
db_close();	
}

?>