// JavaScript Document
function resetValheight(val)
	{
		
		
		frm = document.forms["submit"]
		if((frm.height.value=="Height") && val=="height")
		{
			frm.height.value="";
		}		
	}
function setValheight(val)
	{
		frm = document.forms["submit"]

		if((frm.height.value=="") && val=="height")
		{
			frm.height.value="Height";
		}
		
	}
function resetValwidth(val)
	{
		
		
		frm = document.forms["submit"]
		if((frm.width.value=="Width") && val=="width")
		{
			frm.width.value="";
		}		
	}
function setValwidth(val)
	{
		frm = document.forms["submit"]

		if((frm.width.value=="") && val=="width")
		{
			frm.width.value="Width";
		}
		
	}
// NUMBER------------------------------------
function checknumber(checkno)
{
	
	var str = checkno;   
	for (var k = 0; k < str.length; k++)
		   {      
		   var s = str.substring(k, k + 1);      
		   if ((s < "0" || "9" < s || s==".")) 
		   {  
			return false;        
		   }      
		   } 
	return true;
}
function checkform()
{
//NAME ------------------------------------
	if(document.submit.name.value == "")
		{
			alert("Please enter your Full Name!");
			document.submit.name.focus();
			return false;
		}
		
		invalid = ".#@_-~/:<>`|^!';$%^&*()+|=1234567890";
			charvalue = document.submit.name.value ;
			for(i=0;i<invalid.length;i++)
			{
				for(j=0;j<invalid.length;j++)
				{
					if(charvalue.charAt(j) ==  invalid.charAt(i))
					{
						alert("Only valid characters are allowed in Name") ;
						document.submit.name.select();  
						return(false);
					}
				}
			}
			var spacecount = 0
			for(i=0;i<charvalue.length;i++)
			{
				if(charvalue.charAt(i) == " ")
				{   
					spacecount++ ;
					if (spacecount == charvalue.length)
					{
					alert("lease enter your Full Name") ;
					return(false);
					}		
				}
			}

//EMAIL ID------------------------------------
if(document.submit.emailid.value=="")
{
	alert("Please enter your Email ID!");
	document.submit.emailid.focus();
	return false;
}
if (!isEmailAddr(document.submit.emailid.value)) 
  	{
		alert("Email ID seems incorrect!");
		document.submit.emailid.focus();
		document.submit.emailid.select();
		return (false);
	}

//Company URL ------------------------------------
	/*if(document.submit.company_url.value == "" ||document.submit.company_url.value == "http://")
		{
			alert("Please enter your Company URL!");
			document.submit.company_url.focus();
			return false;
		}
		
		invalid = "#@_-~<>`|^!';$%^&*()+|=";
			charvalue = document.submit.company_url.value ;
			for(i=0;i<invalid.length;i++)
			{
				for(j=0;j<invalid.length;j++)
				{
					if(charvalue.charAt(j) ==  invalid.charAt(i))
					{
						alert("Company URL seems incorrect!") ;
						document.submit.company_url.select();  
						return(false);
					}
				}
			}
			var spacecount = 0
			for(i=0;i<charvalue.length;i++)
			{
				if(charvalue.charAt(i) == " ")
				{   
					spacecount++ ;
					if (spacecount == charvalue.length)
					{
					alert("Please enter your Company URL!") ;
					return(false);
					}		
				}
			}
	*/		
	//Game Name ------------------------------------
	if(document.submit.game_title.value == "")
		{
			alert("Please enter the Game Title!");
			document.submit.game_title.focus();
			return false;
		}
		
		invalid = ".#@_-~/:<>`|^!';$%^&*()+|=0";
			charvalue = document.submit.game_title.value ;
			for(i=0;i<invalid.length;i++)
			{
				for(j=0;j<invalid.length;j++)
				{
					if(charvalue.charAt(j) ==  invalid.charAt(i))
					{
						alert("Game Title seems incorrect") ;
						document.submit.game_title.select();  
						return(false);
					}
				}
			}
			var spacecount = 0
			for(i=0;i<charvalue.length;i++)
			{
				if(charvalue.charAt(i) == " ")
				{   
					spacecount++ ;
					if (spacecount == charvalue.length)
					{
					alert("Please enter the Game Title!") ;
					return(false);
					}		
				}
			}
			
	//demo URL ------------------------------------
	if(document.submit.game_demo_url.value == "" ||document.submit.game_demo_url.value == "http://")
		{
			alert("Please enter Game Demo URL!");
			document.submit.company_url.focus();
			return false;
		}
		
		invalid = "#@_-~<>`|^!';$%^&*()+|=";
			charvalue = document.submit.game_demo_url.value ;
			for(i=0;i<invalid.length;i++)
			{
				for(j=0;j<invalid.length;j++)
				{
					if(charvalue.charAt(j) ==  invalid.charAt(i))
					{
						alert("Demo URL seems incorrect") ;
						document.submit.game_demo_url.select();  
						return(false);
					}
				}
			}
			var spacecount = 0
			for(i=0;i<charvalue.length;i++)
			{
				if(charvalue.charAt(i) == " ")
				{   
					spacecount++ ;
					if (spacecount == charvalue.length)
					{
					alert("Please enter Game Demo URL!") ;
					return(false);
					}		
				}
			}
			
//Description------------------------------------
if(document.submit.game_description.value=="")
{
	alert("Please enter Game Description!");
	document.submit.game_description.focus();
	return false;
}		
//Instructions------------------------------------
if(document.submit.game_instruction.value=="")
{
	alert("Please enter Game Instructions!");
	document.submit.game_instruction.focus();
	return false;
}	
//Levels ------------------------------------
if(document.submit.levels.value=="")
{
	alert("Please enter number of Levels!");
	document.submit.levels.focus();
	return false;
}	
if (!checknumber(document.submit.levels.value)) 
  	{
		alert("Please enter the proper number of Levels!");
		document.submit.levels.focus();
		document.submit.levels.select();
		return (false);
	}
//Diamentions ------------------------------------
if(document.submit.width.value=="Width" || document.submit.width.value=="")
{
	alert("Please enter Game Dimensions!");
	document.submit.width.focus();
	return false;
}	
if (!checknumber(document.submit.width.value)) 
  	{
		alert("Please enter the proper Game Dimensions!");
		document.submit.width.focus();
		document.submit.width.select();
		return (false);
	}
if(document.submit.height.value=="Height" || document.submit.width.value=="")
{
	alert("Please enter Game Dimensions!");
	document.submit.height.focus();
	return false;
}
if (!checknumber(document.submit.height.value)) 
  	{
		alert("Please enter the proper Game Dimensions!");
		document.submit.height.focus();
		document.submit.height.select();
		return (false);
	}
//Game Size------------------------------------
if(document.submit.game_size.value=="")
{
	alert("Please enter Game Size!");
	document.submit.game_size.focus();
	return false;
}	
if (!checknumber(document.submit.game_size.value)) 
  	{
		alert("Please enter the proper Game Size!");
		document.submit.game_size.focus();
		document.submit.game_size.select();
		return (false);
	}
if (!checknumber(document.submit.price.value)) 
  	{
		alert("Please enter the proper Price!");
		document.submit.price.focus();
		document.submit.price.select();
		return (false);
	}
//AGREE
if(!document.submit.sponsership.checked)
{
	alert("You have to agree to the Games2win Sponsorship Terms!");
	document.submit.sponsership.focus();
	return false;
}

}
function isEmailAddr(email)
{
  if(email.match(" ") == " ")
	{
		return false;
	}
	if(email.indexOf(".") == -1 || email.indexOf("@") == -1)
	{
		return false;
	}
	if(email.indexOf(".") == 0 || email.lastIndexOf("@") == email.length-1 || email.lastIndexOf(".") == email.length-1 || email.indexOf("@") == 0)
	{
		return false;
	}
	if(email.match(".@")==".@" || email.match("@.")=="@.")
	{
		return false;
	}
  return true;
}