function clickEvent()
{
}

function Select_All(frmName,checkBoxName,flag)//Function For Select check box
{
	var frm = eval("document."+frmName);
	var chkObj = frm[checkBoxName];
	var total_records_viewed;

	if(chkObj)
	{
		if(chkObj.length == undefined)
		{
			chkObj.checked = flag;
			//total_records_viewed = 1;
		}
		else
		{
			total_records_viewed = chkObj.length;
	
			for(var i=0;i<total_records_viewed;i=i+1)
			{				
				chkObj[i].checked = flag;
			}
		}
	}
}





function isValidURL(url){
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    if(RegExp.test(url)){
        return true;
    }else{
        return false;
    }
} 


/* This function checkForm() is uded for form validation . */

	function checkForm(obj)
	{
		var theMessage = "You entered incorrectly or forgot to fill in ::\n";
		var noErrors = theMessage;
		var focusval = obj.state_name;

		if(obj.state_name)
		{
			if(trimAll(obj.state_name.value).length<=0)
			{
				theMessage+= "\nPlease enter state name";
				focusval = obj.state_name;
			}
			else if(!isNaN(obj.state_name.value))
			{
				theMessage+= "\nPlease provide valid state name";
				focusval = obj.state_name;
			}
		}
	
		if(obj.page_title)
		{
			if(trimAll(obj.page_title.value).length<=0)
			{
				theMessage+= "\nPlease enter page title";
				focusval = obj.page_title;
			}
		}



		if(obj.page_keywords)
		{
			if(trimAll(obj.page_keywords.value).length<=0)
			{
				theMessage+= "\nPlease enter page keywords";
				focusval = obj.page_keywords;
			}
		}


		if(obj.page_description)
		{
			if(trimAll(obj.page_description.value).length<=0)
			{
				theMessage+= "\nPlease enter page description ";
				focusval = obj.page_description;
			}
		}

		if (theMessage == noErrors) {
			return true;
		} 
		else
		{
			alert(theMessage);
			focusval.focus();

			return false;
		}
	}///end of function checkForm().




function validateForm(obj)
	{
		var theMessage = "You entered incorrectly or forgot to fill in ::\n";
		var noErrors = theMessage;
		var focusval = obj.state_name;

		if(obj.name )
		{
			if(trimAll(obj.name.value).length<=0)
			{
				theMessage+= "\nPlease enter name";
			}
		}
		
		if(obj.mobile )
		{
			if(trimAll(obj.mobile.value).length<=0)
			{
				theMessage+= "\nPlease enter mobile";
			}
		}

		if(obj.email )
		{
			if(trimAll(obj.email.value).length<=0)
			{
				theMessage+= "\nPlease enter email";
			}else if(!isValidEmail(obj.email.value))
			{
				theMessage+= "\nPlease enter valid email";
			}
		}

		if(obj.message )
		{
			if(trimAll(obj.message.value).length<=0)
			{
				theMessage+= "\nPlease enter message";
			}
		}

		if (theMessage == noErrors) {
			return true;
		} 
		else
		{
			alert(theMessage);
			return false;
		}


	}//end function


function isValidEmail(sFieldValue)
{
	var REmail=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

	var str=sFieldValue;
	if(!str.match(REmail)){
		return false;
	}
	else
	{
		return true;
	}
}


function checkField(fldObj, strtext)
{
	if (trim(fldObj.value) == "") 
	{
		fldObj.focus();
		alert (strtext);
		return false;
	}
	
	return true;
}


function checkfornum(str1) 
{
	//This function checks for numeric values
	var numstr="1234567890 ,";
	var intctr,intLen;
	intLen=str1.length;
	for(intCtr=0;intCtr <= intLen && numstr.indexOf(str1.charAt(intCtr))>=0 ;intCtr++);
	if(intCtr > intLen)
	{
		return 1;
	}
	else
	{
		return 0;
	}

}



//////////////
function checkforchar(strdate)
{
	//This function checks for string values
	var validdate = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var strlength = strdate.length;
	for(var i=0; i<=strlength; i++)
	{
		var unitstr = strdate.substr(i,1);
		if (validdate.indexOf(unitstr)==-1)
		{
			return false;
		}
	}
	return true;
}




///////////////////
function trim(str1)
{
	// This function trims any given field value for blank spaces.
	var intCtr=0
	for(intCtr=0;str1.charAt(intCtr)==" ";intCtr++);
	str1=str1.substring(intCtr,str1.length);
	return str1; 
}



function refreshParent()
{
	window.opener.location.href = window.opener.location.href;
	window.opener.location.reload(true);
	if (window.opener.progressWindow)
	{
		window.opener.progressWindow.close();
	}
}


function notyping(obj)  // function to restrict typing in image browing field
{
	if(event.keyCode != 32)
	{
		alert("You can not write in file name directly.\n Please click on Browse");
		obj.blur();
		return false;
	}
	else
	{
		return true;
	}
}

//////////function for maxlength in textarea
function ismaxlength(obj)
{
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : "";

	if (obj.getAttribute && obj.value.length > mlength)
	{
		obj.value = obj.value.substring(0, (mlength-1));
		alert("The maximum character limit (3000 characters) has been crossed .");
		return false;
	}
	else
	{
		return true;
	}
}
/*****************changes done on 30Jan 2008 ***********************************/
function action_entry(formName, checkbox, promptName, formAction)
{
	/**	Function selectone() is used to ensure that 
	 *	whether at least one check box exist on the form is checked or not.
	 */

	chk		=	checkField(formName,checkbox);
	
	if(!chk)
	{
		alert("Please check atleast one.");
		
		return false;
	}
	else
	{
		///ask the user for confirmation about the action.
		var agree= confirm("Do you really want to "+ promptName +" ");

		if (agree== true)											///if 'Yes'
		{
			formName.action_mode.value= promptName;	
			formName.action= formAction;						///change the action of the form
			return true;
		}
		else														///if 'No'
		{
			return false ;
		}///end of else if case
	}
	
}///end of function




function deletePic(formName, post_id , promptName, formAction)
{
	/**	Function selectone() is used to ensure that 
	 *	whether at least one check box exist on the form is checked or not.
	 */
	alert(post_id);
	if(post_id<='0')
	{
		alert("Oops!! wrong path");
		
		return false;
	}
	else
	{
		///ask the user for confirmation about the action.
		var agree= confirm("Do you really want to "+ promptName +" ");

		if (agree== true)											///if 'Yes'
		{
			formName.action_mode.value= promptName;	
			formName.action= formAction;						///change the action of the form
			//alert(formName.action);
			formName.submit();
			return true;
		}
		else														///if 'No'
		{
			return false ;
		}///end of else if case
	}
	
}///end of function


function checkField(frmName, ChkBoxName)
{
	var objCheck = frmName[ChkBoxName];
	
	if(objCheck == undefined)
	{
		return false;
	}
	else
	{
		myRecpArray = new Array();
		var flag = '';
		if(myRecpArray.length >0)
		{
			myRecpArray = myRecpArray.shift();
		}

		var ct = 0;
		if(objCheck.length == undefined)
		{
			if (objCheck.checked)
			{
				flag = true;
				myRecpArray[ct] = objCheck.value;
				ct++;
				
			}
		}
		else
		{
			myRecpArray = new Array();
			for (i = 0; i < objCheck.length; i++)
			{
				if (objCheck[i].checked)
				{
					flag = true;
					myRecpArray[ct] = objCheck[i].value;
					ct++;
				}
			
			}
			//alert(myRecpArray)
			
		}

		return flag;
	}

}

function checkIt(formName, btName, checkbox) 
{
	
	var objCheck = formName[checkbox];
	//alert(objCheck.length);

	if(objCheck)
	{
		/// if main check box is checked.
		if (formName[btName].checked == true)  
		{
				//if only one check box exist in form.
			if(objCheck.length == undefined)   
			{											
				objCheck.checked = true;								//make that check box as checked
			}
			else
			{
				///if more then one check box exist in form
				for (i = 0; i < objCheck.length; i++)
				{
					objCheck[i].checked = true;					//make all existing check box as checked
				}///end of for loop
			}///end of else if case.
		}///end of if case that check wether main check box is checked or not.
		else														///if main check box is not checked
		{
			///if only one check box exist in form.
			if(objCheck.length == undefined)
			{
				objCheck.checked = false;
			}
			///if more then one check box exist in form
			for (i = 0; i < objCheck.length; i++)
			{
				objCheck[i].checked = false;
			}///end of for loop.
		}///end of else case
	}

}//end of function


/** This function is used in sorting the form according to a field name with particuler order 
 *	sBy is sort by, i.e. whether in ascending or descending
 *	sOrder is sort order, means on which table fields sorting is done
 */
function sort_result(frmName, sBy, sOrder)
{
	var form			= frmName;
	form.sortBy.value	= sBy;	
	form.sortOrder.value= sOrder;
	form.submit();
	return true;

}/// end of function


/** This function goPage() starts
 * It is responsible for specifying limitstart in paging of records while navigating through records 
 */

function goPage(frmName, iPage)
{
	//alert(document.forms[frmName].task_action.value);

	document.forms[frmName].limitstart.value = iPage;
	document.forms[frmName].submit();
	return true;

}//end of function goPage()

//function to trim the given string
function trimAll(str){
	if(str.length>0)
	{
		var l=0;
		var r=str.length;
		while((ch=str.charAt(l++)) == ' ');
		while((ch=str.charAt(--r)) == ' ');
		return(0>r)?"":str.substring(l-1,r+1);
	}
	return str;
}
/** This function goPage() starts
 * It is responsible for specifying limitstart in paging of records while navigating through records 
 */

function goPage(frmName, iPage)
{
	//alert(document.forms[frmName].task_action.value);

	document.forms[frmName].limitstart.value = iPage;
	document.forms[frmName].submit();
	return true;

}//end of function goPage()
	function formSubmit(frmName, fAction)
	{
		var form	= frmName;
		form.action = fAction;
		form.submit();
		return true;
	}






function filterNum1(temp)
{
         //  var re = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";

          // remove special characters like "$" and "," etc...
         // return str.replace(re, "-");
		
		
		temp =  temp.replace(/[^a-zA-Z 0-9]+/g,'');
		
		temp = 		ltrim1(rtrim1(temp, ''), '');
		
		var temp1 = "";
		for(i=0;i<=temp.length-1;i++)
		{
			
			if(temp[i]==" ")
			{
				if(i>0)
				{
					
					if((temp[i-1]==" ")&& (temp[i]==" "))
					{ }else{temp1 += '-';}
				}
				
			}else
			{
				temp1 += temp[i];
			}
			
		}

		return temp1.toLowerCase();

    }



function ltrim1(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim1(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
