﻿// isEmpty , Check for Empty
var strIsEmpty = "Please enter";

function IsEmpty (Control , Caption)
{
	Trim(Control);
	if(Control.value.length == 0 ) 
	{
	//	alert( Caption + " " + strIsEmpty);
		alert(strIsEmpty + " " + Caption);
		Control.focus();
		Control.select();		
		return true;
	}
	return false;
}
function Trim (Control)
{
	var value = Control.value;
	
	for ( var i = 0 ; value != null && i < value.length ; i++ )
	{
		if ( value.charAt(i) != ' ' )
		{
			value = value.substring(i);
			break;
		}
		
		if ( i == value.length -1 )
		{
			value = '';
		}
	}

	for ( var i = value != null ? value.length - 1 : -1 ; i >= 0 ; i-- )
	{
		if ( value.charAt(i) != ' ' )
		{
			value = value.substring(0, i + 1);
			break;
		}
		
		if ( i == 0 )
		{
			value = '';
		}
	}
	
	Control.value = value;
	
}
function ValidateNewsFields(txtTitleName)
{
if(IsEmpty(document.getElementById(txtTitleName),"NOTEWORTHY Title"))return false;
submitForm();
return true;
}
function ValidateLoginPage(txtUserName,txtPasswordName)
{
if(IsEmpty(document.getElementById(txtUserName),"User Id"))return false;
if(IsEmpty(document.getElementById(txtPasswordName),"Password"))return false;
return true;
}

function ShowEditControls()
    {
    document.getElementById("ctl00_ContentPlaceHolder1_td_dgrid").style.display = 'none';
    document.getElementById("ctl00_ContentPlaceHolder1_rt_txtField1").style.display = 'inline';
    document.getElementById("ctl00_ContentPlaceHolder1_rt_txtField2").style.display = 'inline';
    document.getElementById("ctl00_ContentPlaceHolder1_uc_imgUploader").style.display = 'inline';
    document.getElementById("ctl00$ContentPlaceHolder1$btnAdd").style.display = 'none';
    document.getElementById("ctl00$ContentPlaceHolder1$btnUpdate").style.display = 'inline';
    
    }

    
    function ShowLoadControls()
    {
    document.getElementById("ctl00_ContentPlaceHolder1_rt_txtField1").style.display = 'none';
    document.getElementById("ctl00_ContentPlaceHolder1_rt_txtField2").style.display = 'none';
    document.getElementById("ctl00_ContentPlaceHolder1_uc_imgUploader").style.display = 'none';
    document.getElementById("ctl00$ContentPlaceHolder1$btnUpdate").style.display = 'none';
    document.getElementById("ctl00$ContentPlaceHolder1$TextBox1").style.display = 'none';
    }
    
    