function getfileextension(inputId) {
		var fileinput =	inputId;
		if(!fileinput ) return ""; 
		var slash = fileinput.lastIndexOf("\\");
		var filename= fileinput.substr(slash,fileinput.length); 
		if( filename.length == 0 ) return "";
		var dot = filename.lastIndexOf("."); 
		if( dot == -1 ) return "";  
		var extension = filename.substr(dot,filename.length); 
		return extension; 
	} 

	function checkfileType(inputId,allowedExt) {
		var ext = getfileextension(inputId);
		if( ext == allowedExt ) {
		return true;
		}
		else{  
		alert("Only "+allowedExt+" allowed");
		return false;
		}
	} 

function checkGameUpload(){
	var iChars = "!@#$%^&*+=-+\\\,/{}|\"<>?";
	var iCharsAlpha="!@#%$^&=?<>.*/+}()=-abcdefghijklmnopqurstuvwxyz";
	var gdesc=document.getElementById("gamedesc").value;
	var t2desc=document.getElementById("tab2desc").value;
	var t3desc=document.getElementById("tab3desc").value;
	var t5desc=document.getElementById("tab5desc").value;
	//var radioChk=document.getElementById("bkground").checked;
	if(document.gameUpload.product_id.value==""){
			alert("Enter Product Id");
			document.gameUpload.product_id.focus();
			return false;
	}	
	for(var i = 0; i < document.gameUpload.product_id.value.length; i++) {
	if (iCharsAlpha.indexOf(document.gameUpload.product_id.value.charAt(i)) != -1) {
			alert ("Enter Numeric Digit");
			document.gameUpload.product_id.value='';
			document.gameUpload.product_id.focus();
			return false;
		}
	}

	if(document.gameUpload.game_name.value==""){
			alert("Enter Game Name");
			document.gameUpload.game_name.focus();
			return false;
	}	
	for(var i = 0; i < document.gameUpload.game_name.value.length; i++) {
	if (iChars.indexOf(document.gameUpload.game_name.value.charAt(i)) != -1) {
			alert ("Enter Valid Game Name");
			document.gameUpload.game_name.value='';
			document.gameUpload.game_name.focus();
			return false;
		}
	}
	if(document.gameUpload.shot_name.value==""){
			alert("Enter Short Name");
			document.gameUpload.shot_name.focus();
			return false;
	}
	for(var i = 0; i < document.gameUpload.shot_name.value.length; i++) {
	if (iChars.indexOf(document.gameUpload.shot_name.value.charAt(i)) != -1) {
			alert ("Enter Valid Short Game Name");
			document.gameUpload.shot_name.value='';
			document.gameUpload.shot_name.focus();
			return false;
		}
	}
	if(gdesc.length==0){
		alert("Enter Game Decsription");
		document.gameUpload.gamedesc.focus();
		return false;
	}
	if(document.gameUpload.tab2_name.value==""){
			alert("Enter Tab2 value");
			document.gameUpload.tab2_name.focus();
			return false;
	}
	for(var i = 0; i < document.gameUpload.tab2_name.value.length; i++) {
	if (iChars.indexOf(document.gameUpload.tab2_name.value.charAt(i)) != -1) {
			alert ("Enter Valid Tab2 Value");
			document.gameUpload.tab2_name.value='';
			document.gameUpload.tab2_name.focus();
			return false;
		}
	}
	if(document.gameUpload.tab2_display.value==""){
			alert("Enter Tab2 display value");
			document.gameUpload.tab2_display.focus();
			return false;
	}
	for(var i = 0; i < document.gameUpload.tab2_display.value.length; i++) {
	if (iChars.indexOf(document.gameUpload.tab2_display.value.charAt(i)) != -1) {
			alert ("Enter Valid Tab2 display Value");
			document.gameUpload.tab2_display.value='';
			document.gameUpload.tab2_display.focus();
			return false;
		}
	}
	if(t2desc.length==0){
		alert("Enter Tab 2 Decsription");
		document.gameUpload.tab2desc.focus();
		return false;

	}
	if (document.gameUpload.tab3_name.value==""){
			alert("Enter Tab3 value");
			document.gameUpload.tab3_name.focus();
			return false;
	}
	for(var i = 0; i < document.gameUpload.tab3_name.value.length; i++) {
	if (iChars.indexOf(document.gameUpload.tab3_name.value.charAt(i)) != -1) {
			alert ("Enter Valid Tab3  Value");
			document.gameUpload.tab3_name.value='';
			document.gameUpload.tab3_name.focus();
			return false;
		}	
	}
	if(document.gameUpload.tab3_display.value==""){
			alert("Enter tab3 value");
			document.gameUpload.tab3_display.focus();
			return false;
	}
	for(var i = 0; i < document.gameUpload.tab3_display.value.length; i++) {
	if (iChars.indexOf(document.gameUpload.tab3_display.value.charAt(i)) != -1) {
			alert ("Enter Valid Tab3 Display Value");
			document.gameUpload.tab3_display.value='';
			document.gameUpload.tab3_display.focus();
			return false;
		}
	}
	if(t3desc.length==0){
		alert("Enter Tab 3 Decsription");
		document.gameUpload.tab3desc.focus();
		return false;

	}
	if(document.gameUpload.tab4_name.value==""){
			alert("Enter tab4 value");
			document.gameUpload.tab4_name.focus();
			return false;
	}
	for(var i = 0; i < document.gameUpload.tab4_name.value.length; i++) {
	if (iChars.indexOf(document.gameUpload.tab4_name.value.charAt(i)) != -1) {
			alert ("Enter Valid Tab4  Value");
			document.gameUpload.tab4_name.value='';
			document.gameUpload.tab4_name.focus();
			return false;
		}
	}
	if(document.gameUpload.tab4_display.value==""){
			alert("Enter tab4 value");
			document.gameUpload.tab4_display.focus();
			return false;
	}
	for(var i = 0; i < document.gameUpload.tab4_display.value.length; i++) {
	if (iChars.indexOf(document.gameUpload.tab4_display.value.charAt(i)) != -1) {
			alert ("Enter Valid Tab4 Display Value");
			document.gameUpload.tab4_display.value='';
			document.gameUpload.tab4_display.focus();
			return false;
		}
	}
	if(document.gameUpload.tab5_name.value==""){
			alert("Enter tab5 value");
			document.gameUpload.tab5_name.focus();
			return false;
	}
	for(var i = 0; i < document.gameUpload.tab5_name.value.length; i++) {
	if (iChars.indexOf(document.gameUpload.tab5_name.value.charAt(i)) != -1) {
			alert ("Enter Valid Tab5  Value");
			document.gameUpload.tab5_name.value='';
			document.gameUpload.tab5_name.focus();
			return false;
		}
	}
	if(document.gameUpload.tab5_display.value==""){
			alert("Enter tab5 Display value");
			document.gameUpload.tab5_display.focus();
			return false;
	}
	for(var i = 0; i < document.gameUpload.tab5_display.value.length; i++) {
	if (iChars.indexOf(document.gameUpload.tab5_display.value.charAt(i)) != -1) {
			alert ("Enter Valid Tab5 Display Value");
			document.gameUpload.tab5_display.value='';
			document.gameUpload.tab5_display.focus();
			return false;
		}
	}
	if(t5desc.length==0){
		alert("Enter Tab 5 Decsription");
		document.gameUpload.tab5desc.focus();
		return false;

	}
	
	if(document.gameUpload.textColorId.value==""){
			alert("Select Text color");
			document.gameUpload.textColorId.focus();
			return false;
	}
	if(document.gameUpload.colorId.value==""){
			alert("Select border color");
			document.gameUpload.colorId.focus();
			return false;
	}
	if(document.gameUpload.NavColorId.value==""){
			alert("Select Navigation color");
			document.gameUpload.NavColorId.focus();
			return false;
	}
	var backid=document.getElementById("backgroundImage");
	var button=document.getElementById("button");
	var bid=document.getElementById("backgroundColorId");
	var radioChk=document.getElementById("bkground").checked;

	if(radioChk){
		if(document.gameUpload.backgroundColorId.value==''){
			alert("Select Background Color");
			document.gameUpload.backgroundImage.value='';
			document.gameUpload.backgroundColorId.focus();
			backid.disabled=true;
			return false;
		}
		
	}else{
		if(document.gameUpload.backgroundImage.value==''){
		alert("Upload Background Image");
		document.gameUpload.backgroundColorId.value='';
		document.gameUpload.backgroundImage.focus();
		button.disabled=true;
		bid.disabled=true;
		return false;		

		}
	}
	
	if(document.gameUpload.backgroundImage.value!=''){
		ext = getfileextension(document.gameUpload.backgroundImage.value);
			if(ext!='.gif' && ext!='.jpg'){
				alert("Only .jpg & .jif Image allowed");
				document.gameUpload.backgroundImage.value='';
				document.gameUpload.backgroundImage.focus();
				return false;
			}
			
	}
	
	if(document.gameUpload.header_image.value==""){
			alert("Upload Header Image");
			document.gameUpload.header_image.focus();
			return false;
	}
	
	if(document.gameUpload.header_image.value != "" ){
			flag=checkfileType(document.gameUpload.header_image.value,".jpg");
				if(!flag){
					document.gameUpload.header_image.value='';
					document.gameUpload.header_image.focus();
					return false;
				}
	}
	if(document.gameUpload.bgImage.value==""){
			alert("Upload Background Image");
			document.gameUpload.bgImage.focus();
			return false;
	}
	if(document.gameUpload.bgImage.value!= ""){
			flag=checkfileType(document.gameUpload.bgImage.value,".jpg");
				if(!flag){
					document.gameUpload.bgImage.value='';
					document.gameUpload.bgImage.focus();
					return false;
		}
	}
	if(document.gameUpload.netBgImage.value==""){
			alert("Upload Net Background Image");
			document.gameUpload.netBgImage.focus();
			return false;
	}
	if(document.gameUpload.netBgImage.value != "" ){
			flag=checkfileType(document.gameUpload.netBgImage.value,".gif");
				if(!flag){
					document.gameUpload.netBgImage.value='';
					document.gameUpload.netBgImage.focus();
					return false;
		}
	}

	if(document.gameUpload.shotimage1.value==""){
			alert("Upload Thumbnail 1");
			document.gameUpload.shotimage1.focus();
			return false;
	}
	if(document.gameUpload.shotimage1.value != "" ){
			flag=checkfileType(document.gameUpload.shotimage1.value,".gif");
				if(!flag){
					document.gameUpload.shotimage1.value='';
					document.gameUpload.shotimage1.focus();
					return false;
				}
	}
	if(document.gameUpload.image_preview1.value==""){
			alert("Upload Image Preview 1");
			document.gameUpload.image_preview1.focus();
			return false;
	}
	if(document.gameUpload.image_preview1.value != "" ){
			flag=checkfileType(document.gameUpload.image_preview1.value,".jpg");
				if(!flag){
					document.gameUpload.image_preview1.value='';
					document.gameUpload.image_preview1.focus();
					return false;
				}
	}
	if(document.gameUpload.shotimage2.value==""){
			alert("Upload Thumbnail 2");
			document.gameUpload.shotimage2.focus();
			return false;
	}
	if(document.gameUpload.shotimage2.value != "" ){
			flag=checkfileType(document.gameUpload.shotimage2.value,".gif");
				if(!flag){
					document.gameUpload.shotimage2.value='';
					document.gameUpload.shotimage2.focus();
					return false;
				}
	}
	if(document.gameUpload.image_preview2.value==""){
			alert("Upload Image Preview 2");
			document.gameUpload.image_preview2.focus();
			return false;
	}
	if(document.gameUpload.image_preview2.value != "" ){
			flag=checkfileType(document.gameUpload.image_preview2.value,".jpg");
				if(!flag){
					document.gameUpload.image_preview2.value='';
					document.gameUpload.image_preview2.focus();
					return false;
				}
	}		
	if(document.gameUpload.shotimage3.value==""){
			alert("Upload Thumbnail 3");
			document.gameUpload.shotimage3.focus();
			return false;
	}
	if(document.gameUpload.shotimage3.value != "" ){
			flag=checkfileType(document.gameUpload.shotimage3.value,".gif");
				if(!flag){
					document.gameUpload.shotimage3.value='';
					document.gameUpload.shotimage3.focus();
					return false;
			}
	}
	if(document.gameUpload.image_preview3.value==""){
			alert("Upload Image Preview 3");
			document.gameUpload.image_preview3.focus();
			return false;
	}
	if(document.gameUpload.image_preview3.value != "" ){
			flag=checkfileType(document.gameUpload.image_preview3.value,".jpg");
				if(!flag){
					document.gameUpload.image_preview3.value='';
					document.gameUpload.image_preview3.focus();
					return false;
				}
	}	
	if(document.gameUpload.shotimage4.value==""){
			alert("Upload Thumbnail 4");
			document.gameUpload.shotimage4.focus();
			return false;
	}
	if(document.gameUpload.shotimage4.value != "" ){
			flag=checkfileType(document.gameUpload.shotimage4.value,".gif");
				if(!flag){
					document.gameUpload.shotimage4.value='';
					document.gameUpload.shotimage4.focus();
					return false;
				}
	}
	if(document.gameUpload.image_preview4.value==""){
			alert("Upload Image Preview 4");
			document.gameUpload.image_preview4.focus();
			return false;
	}
	if(document.gameUpload.image_preview4.value != "" ){
			flag=checkfileType(document.gameUpload.image_preview4.value,".jpg");
				if(!flag){
					document.gameUpload.image_preview4.value='';
					document.gameUpload.image_preview4.focus();
					return false;
				}
	}
	if(document.gameUpload.shotimage5.value==""){
			alert("Upload Thumbnail 5");
			document.gameUpload.shotimage5.focus();
			return false;
	}
	if(document.gameUpload.shotimage5.value != "" ){
			flag=checkfileType(document.gameUpload.shotimage5.value,".gif");
				if(!flag){
					document.gameUpload.shotimage5.value='';
					document.gameUpload.shotimage5.focus();
					return false;
				}
	}
	if(document.gameUpload.image_preview5.value==""){
			alert("Upload Image Preview 5");
			document.gameUpload.image_preview5.focus();
			return false;
	}
	if(document.gameUpload.image_preview5.value != "" ){
			flag=checkfileType(document.gameUpload.image_preview5.value,".jpg");
				if(!flag){
					document.gameUpload.image_preview5.value='';
					document.gameUpload.image_preview5.focus();
					return false;
				}
	}
	if(document.gameUpload.shotimage6.value==""){
			alert("Upload Thumbnail 6");
			document.gameUpload.shotimage6.focus();
			return false;
	}
	if(document.gameUpload.shotimage6.value != "" ){
			flag=checkfileType(document.gameUpload.shotimage6.value,".gif");
				if(!flag){
					document.gameUpload.shotimage6.value='';
					document.gameUpload.shotimage6.focus();
					return false;
				}
	}
	if(document.gameUpload.image_preview6.value==""){
			alert("Upload Image Preview 6");
			document.gameUpload.image_preview6.focus();
			return false;
	}
	if(document.gameUpload.image_preview6.value != "" ){
			flag=checkfileType(document.gameUpload.image_preview6.value,".jpg");
				if(!flag){
					document.gameUpload.image_preview6.value='';
					document.gameUpload.image_preview6.focus();
					return false;
				}
	}
	if(document.gameUpload.video_file.value==""){
			alert("Upload Video file");
			document.gameUpload.video_file.focus();
			return false;
	}
	if(document.gameUpload.video_file.value != "" ){
			flag=checkfileType(document.gameUpload.video_file.value,".swf");
				if(!flag){
					document.gameUpload.video_file.value='';
					document.gameUpload.video_file.focus();
					return false;
				}
	}
	if(document.gameUpload.flash1.value==""){
			alert("Upload Flash Support Swf File");
			document.gameUpload.flash1.focus();
			return false;
	}
	if(document.gameUpload.flash1.value != "" ){
			flag=checkfileType(document.gameUpload.flash1.value,".swf");
				if(!flag){
					document.gameUpload.flash1.value='';
					document.gameUpload.flash1.focus();
					return false;
				}
	}
	if(document.gameUpload.flash2.value==""){
			alert("Upload Flash Support Flv file");
			document.gameUpload.flash2.focus();
			return false;
	}
	if(document.gameUpload.flash2.value != "" ){
			flag=checkfileType(document.gameUpload.flash2.value,".flv");
				if(!flag){
					document.gameUpload.flash2.value='';
					document.gameUpload.flash2.focus();
					return false;
				}
	}
	

return true;

}	



