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 checkValidGoPagination(objFrm,total_pages,limit_recs)
	{
		
		var theMessage	= "You entered incorrectly or forgot to fill in ::\n";
		var noErrors	= theMessage;
		var focusval	= '';
		var final_val	= '';

		if(objFrm.getPage)
		{
			if(trimAll(objFrm.getPage.value).length<=0)
			{
				theMessage+= "\nPlease enter page number.";
				if(focusval =='')
				{
					focusval = objFrm.getPage;
				}
			}else 
			{
				if(isNaN(objFrm.getPage.value))
				{
					theMessage +="\n Please enter page in numbers." ;
					if(focusval == '')
					{
						focusval = objFrm.getPage;
					}
				}else if((parseInt(objFrm.getPage.value) <= 0))
				{
					theMessage +="\n Page does not exist." ;
					if(focusval == '')
					{
						focusval = objFrm.getPage;
					}
				}else if((objFrm.getPage.value)>total_pages)
				{
					theMessage +="\n Total pages are " + total_pages + ", You can not enter more then this number." ;
					if(focusval == '')
					{
						focusval = objFrm.getPage;
					}
				}
			
			}
		
		}

		if (theMessage == noErrors)
		{
			if((objFrm.getPage.value)<=0)
			{
				final_val = 0;
			}else if((objFrm.getPage.value)>total_pages)
			{
				final_val = total_pages;
			}else
			{
				final_val = objFrm.getPage.value;
			}
			final_val = parseInt(final_val)-1;
			if(final_val==0)
			{
				window.location.href = "index.html";
			}
			else
			{
				window.location.href = "index"+final_val+".html";
			}
//			objFrm.limitstart.value = countLimit(limit_recs,final_val);
//			objFrm.submit();
			return false;
		} 
		else
		{
			alert(theMessage);
			objFrm.getPage.value = '';
			focusval.focus();
			return false;
		}
	}//end function





/*	This function to check for input type image extensions.
	If extension is  not defined type then it show the alert message.
*/
function validateFileExtensionPhoto(fld) 
{
	if(!/(\.bmp|\.gif|\.png|\.jpg|\.jpeg)$/i.test(fld.value)) // only these extension allowed
	{
		alert("Invalid image file type.");
		fld.value='';
		fld.focus();
		return false;
	}
	else
	{		
		return true;
	}

}// end of 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 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;
    }
} 

function checkField_old(fldObj, strtext)
{
	
	if(trimAll(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 (255 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 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 checkSearchForm(frmObject)
{
	if(frmObject.img_cat.value == '')   //for  category
	{
		alert("Please choose category");
		//frmObject.category.focus();
		return false;
	}
	return true;
}///end function