function delete_confirmation(message_str, url)
{
	if (message_str == "") 
	{
		message_str = "this record";
	}
	else
	{
		message_str = "the " + message_str;
	}
	var r = confirm("Are you sure want to delete " + message_str + " ?")
		if (r==true)
	{
		location.href = url;
	}
}

function validate_photos_form(obj)
{
	return (checkstr(obj.ccd_photo_caption,'caption') && chkimage(obj.ccd_photo_simage) && chkimage(obj.ccd_photo_image)); // && checkstr(obj.ccd_photo_simage,'image') && checkstr(obj.ccd_photo_image,'image'));
}

function validate_top_banner_form(obj)
{
	return (checkstr(obj.fileimage,'image') && chkimage(obj.fileimage)); 
}

function chkimage(obj)
{
	if (Trim(obj.value).length != 0)
	{
		var ext = getfileext(obj.value);
		if (!(ext == ".jpg" || ext == ".png" || ext == ".bmp" || ext == ".gif"))
		{
			alert('Please provide a valid file format for the image. Valid formats are jpg, png, bmp or gif.');
			obj.focus();
			return false;
		}
	}
	return true;
}

function validate_prayer_timing_form(obj)
{
	return (checkstr(obj.excelfile,'excelfile') && chk_excel(obj.excelfile)); 
}

function chk_excel(obj)
{
	if (Trim(obj.value).length != 0)
	{
		var ext = getfileext(obj.value);
		if (!(ext == ".xls"))
		{
			alert('Please provide a valid file format for the file. Valid format is xls.');
			obj.focus();
			return false;
		}
	}
	return true;
}

function validate_multimedia_form(obj)
{
	return (checkstr(obj.mult_file,'audio/video file') && chk_mult(obj.mult_file)); 
}

function chk_mult(obj)
{
	if (Trim(obj.value).length != 0)
	{
		var ext = getfileext(obj.value);
		if (!(ext == ".asx"))
		{
			alert('Please provide a valid file format for the file. Valid format is asx.');
			obj.focus();
			return false;
		}
	}
	return true;
}

function getfileext(filename)
{
	return Trim(filename).substr(Trim(filename).length-4).toLowerCase();
}
function LTrim(str)
	{
		if (str==null){return null;}
		for(var i=0;str.charAt(i)==" ";i++);
		return str.substring(i,str.length);
	}
function RTrim(str)
	{
		if (str==null){return null;}
		for(var i=str.length-1;str.charAt(i)==" ";i--);
		return str.substring(0,i+1);
	}
function Trim(str){return LTrim(RTrim(str));}

function checkstr(obj,errmsg)
{
	if (Trim(obj.value).length == 0)
	{
		alert('Please enter/select a valid ' + errmsg + '.');
		obj.focus();
		return false;
	}
	return true;
}

//<a href="#" onClick="javascript:delete_confirmation('category with name %s', 'manage_category.aspx?action=delete&category_id=..')"></a>