// When pressing ENTER on the object that satisfy the selector, the object with id buttonId will be click
//
function setDefaultButton(selector,buttonId){
	$(selector).bind('keypress',function(e){
    			var keynum=null;
    			if(window.event){
    				keynum=e.keyCode;
    			}
    			else{
    				keynum=e.which;
    			}
    			if(keynum==13)
    			{
    		    	document.getElementById(buttonId).click();
    		    	return false;
    		    }
    		}
    		);
}

// Set focus on the object that satisfy the selector 
//
function setDefaultFocus(selector){	
	$(document).ready(function() {
		$(selector).focus();   		
   });
}

// Check Spelling of HTML object that has the given objid
//
function checkSpelling(objid){
	try{
		var speller=new spellChecker(document.getElementById(objid));
		speller.openChecker();
	}
	catch(err)
	{
		//Handle errors here
		showError(err, "Spell checker is not working!");
	}
}

// Check Spelling of HTML object that has the given objid
//
function checkSpelling2fields(objid1,objid2){
	try{
		var speller=new spellChecker(document.getElementById(objid1),document.getElementById(objid2));
		speller.openChecker();
	}
	catch(err)
	{
		//Handle errors here
		showError(err, "Spell checker is not working!");
	}
}

// Check Spelling of HTML object that has the given objid obtained using jquery
//
function checkSpellingLookId(objkey){
	try{
		var objid = $(objkey).attr("id");		
		var speller=new spellChecker(document.getElementById(objid));
		speller.openChecker();
	}
	catch(err)
	{
		//Handle errors here
		showError(err, "Spell checker is not working!");
	}
}

// showError
//
function showError(verr, label){
	try{		
		alert(label + "\nName: "+ verr.name +"\nMessage: "+ verr.message +"\nDescription: "+ verr.description +"\nLine: "+ verr.number);
	}
	catch(err)
	{
		//Handle errors here
	}	
}
