// IF Called from Object ...............
function chek_alert()
{
	alert('sdfsdf');
}


// call method of this function (IF from onchange)--- 
//	file_filter('jpg','pdf',.....,'cdr',this);
// ---------
// call method of this function (IF from string_Url_chek)--- 
//	if (document.form1.photo_url.value!='')
//  errors+=file_filter('jpg','pdf','cdr',document.form1.photo_url.value);
 
function file_filter()
{
var i=0,j=0;
var t='';
var errors='';
var arg=file_filter.arguments;

// ............... IF Called from Object ...............
var str1=arg[arg.length-1].value;
// ............... IF Called from String Url ...............
var str2=arg[arg.length-1];

if (str1) str=str1; else str=str2; 

if(!str) return errors='File dosen\'t have right format';

var ext=str.substring(str.lastIndexOf(".")+1,str.length);


	for (j=0;j<=arg.length-2;j++)
	{	
		t=t+'.'+arg[j]+'  ';
	}
	//alert(t);
	for (i=0;i<=arg.length-2;i++)
	{	//alert('chek for '+arg[i]);
		//alert(ext+'   '+arg[i]);
		if (arg[i].toUpperCase()!=ext.toUpperCase()) 
		errors='This File dosen\'t have right format. file should be only'+t;
		else 
		{ 	
			if (str1) errors='Yes it is OK';
			else
			errors='';
			break;
		}
	}

	if (!errors)
	{
		filename=str.substring(str.lastIndexOf("\\")+1,str.length);
		//errors=isIncorrectFileName(filename,'File name');
		//alert(errors);
	}
	//alert('This File dosen\'t have right format \n File should be only '+arg);
	

	return errors;
}


function isIncorrectFileName(v1, t1) 
{	var FileName = '';
	var iChars = v1; 
	var data = "`!@#$%^&*()+=- []\\\';,/{}|\":<>?~"; 
	for (var i = 0; i < data.length; i++) 
	{	
		if (iChars.indexOf(data.charAt(i)) != -1) 
		{
		  FileName='Has Special Character';
		}
	}
	if (FileName) return "- "+t1+" has special characters or spaces. These are not allowed.";
	else return ''; 
}



