
//window.onerror = trapError;

function trapError(msg, URI, ln) {
            // wrap our unknown error condition in an object
            var error = new Error(msg);
            error.location = 'Name: '+error.name+'\n\nMessage: '+error.message+'\n\nLocation: '+URI + '\n\nline: ' + ln + '\n\nStack: '+error.stack +'\n\nFile Name: '+error.fileName; // add custom property
            alert(error.location);
            return false; // stop the yellow triangle
}


///////////////////////////////////////////////////////////////////////////////////////
var FastInit = {
	onload : function() {
		if (FastInit.done) { return; }
		FastInit.done = true;
		for(var x = 0, al = FastInit.f.length; x < al; x++) {
			FastInit.f[x]();
		}
	},
	addOnLoad : function() {
		var a = arguments;
		for(var x = 0, al = a.length; x < al; x++) {
			if(typeof a[x] === 'function') {
				if (FastInit.done ) {
					a[x]();
				} else {
					FastInit.f.push(a[x]);
				}
			}
		}
	},
	listen : function() {
		if (/WebKit|khtml/i.test(navigator.userAgent)) {
			FastInit.timer = setInterval(function() {
				if (/loaded|complete/.test(document.readyState)) {
					clearInterval(FastInit.timer);
					delete FastInit.timer;
					FastInit.onload();
				}}, 10);
		} else if (document.addEventListener) {
			document.addEventListener('DOMContentLoaded', FastInit.onload, false);
		} else if(!FastInit.iew32) {
			if(window.addEventListener) {
				window.addEventListener('load', FastInit.onload, false);
			} else if (window.attachEvent) {
				return window.attachEvent('onload', FastInit.onload);
			}
		}
	},
	f:[],done:false,timer:null,iew32:false
};
FastInit.listen();
///////////////////////////////////////////////////////////////////////////////
if (typeof(googleAnalyticsAccount) == 'undefined' || googleAnalyticsAccount==null || googleAnalyticsAccount =="null" || googleAnalyticsAccount==""){
	var googleAnalyticsAccount = null;
}
if (googleAnalyticsAccount && googleAnalyticsAccount != 'null' && trim(googleAnalyticsAccount).length > 0){
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js'"+ " type='text/javascript' ></script%3e"));
}

if (typeof(_mapAPI) == 'undefined' || _mapAPI == null || _mapAPI == "null" || _mapAPI==""){
	var _mapAPI = "GTA";
}

if (_mapAPI.toUpperCase() == "GOOGLE"){
	if (_mapClientId != null && _mapClientId != "null" && _mapClientId.length > 0){
		var gaHost = (("https:" == document.location.protocol) ? "https://maps-api-ssl.google.com" : "http://maps.google.com");
		document.write(unescape("%3Cscript src='" + gaHost + "/maps?file=api&v=2&client="+_mapClientId+"&sensor=false'"+" type='text/javascript' ></script%3e"))
	}else{
		var gaHost = (("https:" == document.location.protocol) ? "https://maps-api-ssl.google.com" : "http://maps.google.com");
		document.write(unescape("%3Cscript src='"+gaHost+"/maps?file=api&v=2&key="+_mapKey+"'"+" type='text/javascript' ></script%3e"))
	}
}else if (_mapAPI.toUpperCase() == "YAHOO"){
	document.write(unescape("%3Cscript src='http://api.maps.yahoo.com/ajaxymap?v=3.8&appid="+_mapKey+"'"+" type='text/javascript' ></script%3e"))
}else if (_mapAPI.toUpperCase() == "GTA"){}


var _dateLocaleFormat = "%m/%d/%Y";
var _dateLocaleFormatToDis = "NNN d, yyyy";
var _dateFormatForServer = "dd-mm-yyyy";
var _dateServerToLocalFormat = "MM/dd/yyyy";
var _currentServerDateTime = new Date();
var _validEndDays =361;
//added by afsar. _validEndDate used to set the calender final date by 361 days from todays date.
if (typeof(_mapAPI) == 'undefined' || _mapAPI == null || _mapAPI == "null" || _mapAPI.length == 0){
	var _mapAPI ="GTA"; //GOOGLE = to Use google Map API, GTA = to Use GTA static Map Image.
}



/******************************** String Constructors *******************************/
/*String.prototype.trim = function() {return trim(this);}
String.prototype.ltrim = function() {return ltrim(this);}
String.prototype.rtrim = function() {return rtrim(this);}
String.prototype.toSentenceCase = function (){return toSentenceCase(this);}
String.prototype.left = function (x){return left(this, x);}
String.prototype.right = function (x){return right(this, x);}
String.prototype.roundOff = function(_fix){return roundOff$(this,_fix) ;} 
String.prototype.toDate = function(format){return toDate$(this,format);}
*/

//---------------------------------------------------------------//


//COMLIB JS START
/******************************** String Constructors *******************************/
// remove spaces from left and right side
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
// to remove left side spaces from string
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
// to remove right side spaces from string
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}
// to convert srting into sentence case
String.prototype.toSentenceCase = function (){
	var sAry = this.split('.')
	for (x=0;x<sAry.length;x++){
		sAry[x] = sAry[x].trim().substr(0,1).toUpperCase()+sAry[x].trim().substr(1).toLowerCase()
	}
	return sAry.join('. ')
}
// to get left side string as per length
String.prototype.left = function (x){
	return this.substr(0,x);
}
// to get right side string as per length
String.prototype.right = function (x){
	return this.substr(this.length-x,x);
}
//------------------------------------------
String.prototype.roundOff = function(_fix){
	return roundOff$(this,_fix) ;
} 
// to roundof any number as per _fix
function roundOff$(_Num, _fix){ 
	return (Math.round(_Num * (Math.pow(10, _fix)))/(Math.pow(10, _fix))).toFixed(_fix) ;
} 
//------------------------------------------
String.prototype.toDate = function(format){
	return toDate$(this,format);
}



/******************************** Miscilinious Functions ********************************************************/

//-------------------get object of given id based on given object container -----------------------
function obj$(i,d){
	var d = d || document;
	return d.getElementById(i)
}
//---------------- display object based on given object id --------------------------
function show$(i){
	var o;
	if(typeof(i)=="string") o = obj$(i); else if(typeof(i)=="object") o = i;
	o.style.display='block';
	o.style.visibility='visible'
}
//--------------- hide object based on given object id---------------------------
function hide$(i){
	var o;
	if(typeof(i)=="string") o = obj$(i); else if(typeof(i)=="object") o = i;
	o.style.display='none';
	o.style.visibility='hidden'
}
//--------------- toggle display based on given object id ---------------------------
function toggle$(i){
	var o;
	if(typeof(i)=="string") o = obj$(i);
	if(typeof(i)=="object") o = i;
	if(o.style.display.toLowerCase()=='none' || o.style.visibility.toLowerCase()=='hidden'){
		show$(i);
	} else {
		hide$(i);
	}
}
//------------- set value in the given object id-----------------------------
function setValue$(i,v){
	if(typeof(i)=='string') 
	{
		if(obj$(i))
			obj$(i).value=v;
		else{
			var id2=':'+i;
			obj$(getActualComponentId(id2)).value=v;
		}
	}
	else if(typeof(i)=='object') 
		i.value = v;
}
//---------------- get value of given object id--------------------------
function getValue$(i){
	if(typeof(i)=='string'){ 
		if(obj$(i)){
			return (obj$(i).value+"");
		}else{
			var id2=':'+i;
			return (obj$(getActualComponentId(id2)).value+"");
		}
	}else 
		if(typeof(i)=='object')
			return (i.value+"");
	
	return null;
}

//------------- set innerHTML in the given object id-----------------------------
function setDivValue(i,v){
	setDivValue$(i,v)
}

function setDivValue$(i,v){
	if(typeof(i)=='string') 
		obj$(i).innerHTML= v; 
	else if(typeof(i)=='object') 
		i.innerHTML= v;
}
//---------------- get innerHTML of given object id--------------------------

function getDivValue(i)
{
	return getDivValue$(i);
}

function getDivValue$(i){
	if(typeof(i)=='string') 
		return obj$(i).innerHTML; 
	else if(typeof(i)=='object') 
		return i.innerHTML;
	return null;
}


// to get x,y position of an object
function getObjectPos$(obj){
	var pos = {x: obj.offsetLeft||0, y: obj.offsetTop||0};
	while(obj = obj.offsetParent) {
		pos.x += obj.offsetLeft||0;
		pos.y += obj.offsetTop||0;
	}
	return pos;
}
// to get size of the window
function getWindowSize$(){
	var size = {w:0,h:0};
	//IE
	if(!window.innerWidth){  ////strict mode
		if(!(document.documentElement.clientWidth == 0)){
			size.w = document.documentElement.clientWidth;
			size.h = document.documentElement.clientHeight;
		} else {  ////quirks mode
			size.w = document.body.clientWidth;
			size.h = document.body.clientHeight;
		}
	}else { //w3c
		size.w = window.innerWidth;
		size.h = window.innerHeight;
	}
	return size;
}

// to get object size
function getObjectSize$(e) {
	var size = {w:0, h:0};
	size.w = e.offsetWidth;
	size.h = e.offsetHeight;
	return suze;
}

// to get page scroll position
function getPageScroll$() {
	var pos = {x:0,y:0};
	if(!window.pageYOffset)	{	//strict mode
		if(!(document.documentElement.scrollTop == 0))	{
			pos.y = document.documentElement.scrollTop;
			pos.x = document.documentElement.scrollLeft;
		} else { //quirks mode
			pos.y = document.body.scrollTop;
			pos.x = document.body.scrollLeft;
		}
	} else { //w3c
		pos.y = window.pageYOffset;
		pos.x = window.pageXOffset;
	}
  return { 'x': offsetX, 'y': offsetY };
}

// to include javascript file
function includeJSFile$(srcFile){
	var script = document.createElement('script');
	script.src = srcFile;
	script.type = 'text/javascript';
	var head = document.getElementsByTagName('head')[0];
	head.appendChild(script)
}

// to know browser
function getBrowser$(){
	var agt = navigator.userAgent.toLowerCase();
	var browser = {	ms : agt.indexOf("msie") > 0 ? true : false,
					ns : agt.indexOf('netscape') ? true : false,
					so : agt.indexOf('staroffice') ? true : false,
					op : agt.indexOf('opera') ? true : false,
					wt : agt.indexOf('webtv') ? true : false,
					bx : agt.indexOf('beonex') ? true : false,
					cm : agt.indexOf('chimera') ? true : false,
					np : agt.indexOf('netpositive') ? true : false,
					px : agt.indexOf('phoenix') ? true : false,
					fx : agt.indexOf('firefox') ? true : false,
					sf : agt.indexOf('safari') ? true : false,
					ss : agt.indexOf('skipstone') ? true : false,
					mz : agt.indexOf('mozilla') ? true : false
				}
	return browser;
}

// to insert object after given object
function insertAfter$(new_node, existing_node) {  
	if (existing_node.nextSibling)   
		existing_node.parentNode.insertBefore(new_node, existing_node.nextSibling);
	else
		existing_node.parentNode.appendChild(new_node);
}

// to set cookies
function setCookie$( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires )
		expires = expires * 1000 * 60 * 60 * 24;
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name + "=" +value + (( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + (( path ) ? ";path=" + path : "" ) + (( domain ) ? ";domain=" + domain : "" ) +(( secure ) ? ";secure" : "" );
}

// to get cookies
function getCookie$(name){
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1){
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else {
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1){
		end = dc.length;
	}
	return (dc.substring(begin + prefix.length, end));
}
// to delete cookies
function deleteCookie$(name, path, domain){
	if (getCookie(name)){
		document.cookie = name + "=" + 
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

// to check date1 greater that date2 by ID
function dateCompareById$(di1,di2,format){
	var d1 = toDate$(getValue$(di1),format);
	var d2 = toDate$(getValue$(di2),format);
	return dateCompare$(d1,d2)
}

// to check date1 greater that date2 by Value
function dateCompareByValue$(dv1,dv2,format){
	return dateCompare$(toDate$(dv1,format),toDate$(dv2,format))
}

// to check date1 greater that date2 by Object
function dateCompare$(do1,do2){
	if (do1== null || do2 == null) return null;
	return ((do2 > do1) ?true:false);
}
// to find date difference in days
function dateDiffById$(di1,di2,format){
	var d1=toDate$(getValue$(di1),format)
	var d2=toDate$(getValue$(di2),format)
	return dateDiff$(d1,d2)
}

// to find date difference in days
function dateDiffByValue$(dv1,dv2,format){
	return dateDiff$(toDate$(dv1,format),toDate$(dv2,format))
}

// to find date difference in days
function dateDiff$(do1,do2){
	if(do1 == null || do2 == null) return 0;
	var timeDiff = do1.getTime() - do2.getTime();
	var dayDiff = timeDiff / 1000 / 60 / 60 / 24;
	return dayDiff
}
// to get max out of two values
function getMax$(v1,v2){
	if (v1 > v2) return v1; else return v2;
}

// to set empty string in the object id
function setEmpty$(id){
	setValue$(id,"")
}


function allowOnlyNumeric$(evt)
{  
   try{
   var charCode = (evt.which) ? evt.which : event.keyCode
   if (charCode > 31 && (charCode < 46 || charCode==47 || charCode > 57))
	   return false;
   }catch(e){
   
   }
	return true;
  
}

function allowOnlyNonSpecialCharacters$(evt)
{  
	
	 try{
   var charCode = (evt.which) ? evt.which : event.keyCode
	   //alert(charCode);
   if ( (charCode < 65 || (charCode > 90 && charCode < 97) || charCode > 122))
	   return false;
   }catch(e){
   
   }
	return true;
  
}

function setInnerHTML$(i,v){
	if(typeof(i)=='string') 
		obj$(i).innerHTML= v; 
	else if(typeof(i)=='object') 
		i.innerHTML= v;
}
//---------------- get innerHTML of given object id--------------------------

function getInnerHTML$(i){
	if(typeof(i)=='string') 
		return obj$(i).innerHTML; 
	else if(typeof(i)=='object') 
		return i.innerHTML;
	return null;
}


//COMLIB JS END

//COMUTIL JS START////////////////////////////////////////////////////////

// to highlight for errors
function removeErrorHighlight(obj){
	if(obj && obj.type != 'button' && obj.style.borderColor.indexOf('red') != -1){
		obj.style.border = 'solid 1px #dcdddf';
		if(obj.parentNode && obj.parentNode.id=="addErrorHighLightDiv")
			obj.parentNode.style.background="#FFFFFF"; 			
  	}
}

function addErrorHighlight(obj){
	if(obj.type != 'button'){
		obj.style.border = 'solid red 1px';
		if(obj.parentNode && obj.parentNode.id=="addErrorHighLightDiv"){
			obj.parentNode.style.background="#ff0000"; 
			obj.parentNode.style.padding = "1";
		}
	}
}


// to remove error highligher from container
function resetErrorHighlight(errId){
	var elements = document.forms[0].elements;
	for(i=0;i<elements.length;i++){
		if(elements[i].type == 'text' || elements[i].tagName == 'TEXTAREA' || elements[i].tagName == 'SELECT' || elements[i].type == 'checkbox' )
			removeErrorHighlight(elements[i]);
	}
	hide$(errId)
}

// to get complete object id based on partial suffixed id
function getActualComponentId(elId){
	var objId;
	var elementsArray = document.forms[0].elements;
	for(i=0;i<elementsArray.length;i++)	{
		var object = elementsArray[i];
		var tId = object.id;
		var xId = elId.indexOf(elId) != -1 ? tId.substr(tId.indexOf(elId)) : tId;
		if(tId.indexOf(elId)!=-1 && elId == xId) {
			objId = object.id;
			break;
		}
	}
	return objId;
}
// Add errors to displayable error Array;
function addToErrorList(errAry,errText,errEl){
	var err = new Array(errText,errEl)
	errAry.push(err);
	return errAry;
}

// Show error message and highlight error object with red color
function showErrorMessages(errPanelId,errAry){
	if(errAry.length > 0){
		var errObj =  obj$(errPanelId);
		var errTable = "<a name='errorBox'></a>"
			errTable+= "<table width='100%' border='0' class='tableborder_tips' cellspacing='2' cellpadding='2'>"
			errTable+= "<tr class='NormalText_12B_white'><td colspan='2' bgcolor='red'>There were "+errAry.length+" Error(s) found in your form</tr>";
		var errText="";
		for (x=0;x<errAry.length ;x++ ){
			errText += "<tr class='FormErrorTips'><td>"+(x+1)+". "+errAry[x][0]+"</td></tr>";
			addErrorHighlight(obj$(errAry[x][1]))
		}
		errText = errTable + errText + "</table>";
		errObj.innerHTML = errText;
		show$(errPanelId);
		location.href="#errorBox";	
	}
}

// to open A4J Richpannel
function openRichPanel(richModalId,pk){
	setValue$(getActualComponentId(':destinationDelete'),pk);
	Richfaces.showModalPanel(''+richModalId,{left:'auto', top:'auto'});
}

// to close A4J Richpannel
function closeRichPanel(richModalId){
	Richfaces.hideModalPanel(richModalId);
}

function checkEmptyFieldValidation(errAry,fieldId,errMsg){
	var field = obj$(getActualComponentId(fieldId));
	if(isEmpty$(getValue$(field))) {
		errAry = addToErrorList(errAry,errMsg,field.id)
	}
	return errAry;
}

function checkFieldLengthValidation(errAry,fieldId,errMsg,fLength){
	var field = obj$(getActualComponentId(fieldId));
	if(field.value.length > fLength) {
		errAry = addToErrorList(errAry,errMsg,field.id)
	}
	return errAry;
}

function checkEmptyFieldAndLengthValidation(errAry,fieldId,emptyErrMsg,lengthErrMsg,fLength){
	var field = obj$(getActualComponentId(fieldId));
	var x= getValue$(field);
	if(isEmpty$(x)) {
		errAry = addToErrorList(errAry,emptyErrMsg,field.id)
	}else if(field.value.length > fLength) {
		errAry = addToErrorList(errAry,lengthErrMsg,field.id)
	}
	return errAry;
}


function checkEmptyFieldAndDateValidation(errAry,fieldId,emptyErrMsg,lengthErrMsg){
	var field = obj$(getActualComponentId(fieldId));
	if(isEmpty$(getValue$(field))) {
		errAry = addToErrorList(errAry,emptyErrMsg,field.id)
	}else if(!isDate$(field.value)) {
		errAry = addToErrorList(errAry,lengthErrMsg,field.id)
	}
	return errAry;
}
function checkDateValidation(errAry,fieldId,errMsg){
	var field = obj$(getActualComponentId(fieldId));
	if(!isEmpty$(field.value)) {
		if(!isDate$(field.value)) 
			errAry = addToErrorList(errAry,errMsg,field.id)
	}
	return errAry;
}

function checkImageFieldValidation(errAry,fieldId,emptyErrMsg){
	var field = obj$(getActualComponentId(fieldId));
	if(!isEmpty$(getValue$(field)) && !isImageFile$(getValue$(field))) {
		errAry = addToErrorList(errAry,emptyErrMsg,field.id)
	}
	return errAry;
}

function showImagInPopup(obj){
	obj1=obj.cloneNode(true)
	var imgHtml = '<img src="'+obj.src+'" style="margin:10px;">'
	var imgPopup= dhtmlmodal.open('imgPopup', 'inline', imgHtml, 'Image', 'title=1,width=500px,drag=1,close=1,height=400px,resize=1,scrolling=0,center=1')

}

function showImageName(imageID,hiddenField){
	var image = obj$(imageID);
	var hiddenField2 = obj$(getActualComponentId(hiddenField))
	if(isEmpty$(hiddenField2.value)){
		hide$(image);
	} else {
		image.src=imgPathForImages+"/"+hiddenField2.value;
		image.style.height = 25
		image.style.width = 25
		image.style.border = '1px solid #c9c9c9'
		image.style.cursor = 'pointer';
		image.style.cursor = 'hand';
	}
}

function setValueOfButton(obj,obj2,hidenField,name){
	setValue$(obj,name)
	var state = "Edit"
	if(name=="Save"){
		state = "Add"
	}
	obj$(obj2).innerHTML=state;
	setValue$(getActualComponentId(hidenField),state.toLowerCase());
}
/*
var contentEditor=false;
function setContentEditor(els){
	tinyMCE.init({
		theme : "advanced",
		mode : "textareas",
		theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
		theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : false,

		// Example content CSS (should be your site CSS)
		content_css : "css/content.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",
		elements : els
	});
}
*/
function parseStringResponse(result){
	  var xmlDoc;
	  if(document.implementation && document.implementation.createDocument) { //Mozilla
		var domParser = new DOMParser();
		xmlDoc = domParser.parseFromString(result, "text/xml");
	  } else if (window.ActiveXObject){ //IE
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async="false";
		xmlDoc.loadXML(result);
	  }
	return xmlDoc;
}

function printCheckBox$(value,name,count,enabled)
{
   var showChecked = false;
	if(value=='1')
		showChecked = true;
	if(!enabled)
		enabled="DISABLED";
	else
		enabled="";

  var htmlStr="";
  htmlStr+="<input type=\"checkbox\" id='"+name+""+count+"'" + (showChecked == true ? "Checked" : String.Empty) +" "+enabled+"/>";
  htmlStr= htmlStr+"</input>";
  return htmlStr;
}

function clearFormValues$(div)
{
		var divObj=obj$(div);
		var allInputElement=divObj.getElementsByTagName('input');
		for(i=0;i<allInputElement.length;i++)
		{
			var elemID=allInputElement[i].getAttribute('id');	
			var elemType=allInputElement[i].getAttribute('type');	
			if(elemType!="button" && elemID)
				setValue$(elemID,'');
			if(elemType=="checkbox")
				document.getElementById(elemID).checked=false;
		}

		var allInputElement=	divObj.getElementsByTagName('select');
		for(i=0;i<allInputElement.length;i++)
		{
			var elemID=allInputElement[i].getAttribute('id');	
			if(elemID)
				setValue$(elemID,'');
		}

		var allInputElement=	divObj.getElementsByTagName('textarea');
		for(i=0;i<allInputElement.length;i++)
		{
			var elemID=allInputElement[i].getAttribute('id');	
			if(elemID)
				setValue$(elemID,'');
		}
}
function getContextPath(){

	var pathname = window.location.pathname;
	var contextPath = pathname.substring( 0, pathname.indexOf("/faces"))+"/faces";
	return contextPath;
}

function airlineErrorImage(el){
	el.src=currentContextPath+"/images/img1.gif";
}

function carErrorImage(el){
   el.src=currentContextPath+"/images/noavailable.gif";
}

/* Loads the XML DOM object from a XMLString/XML file
 * if 'fileType' is 1 then 'xmlString' must hold the XML as a string 
 * if 'fileType' is other than 1 then 'xmlString' must hold the XML filename with path 
 */
function getXmlDom(xmlString,fileType){
	var xmlDomObj;
	var isIE;
	if (document.implementation && document.implementation.createDocument){
		xmlDomObj = document.implementation.createDocument("", "", null);
		isIE=false;
	}else if (window.ActiveXObject){
		xmlDomObj = new ActiveXObject("Microsoft.XMLDOM");
		xmlDomObj.async=false;
        isIE=true;
	}else{
		return;
	}
	if(fileType==1){ //For XML as String
	  if(isIE==false){
		  var parser=new DOMParser();
          xmlDomObj=parser.parseFromString(xmlString,"text/xml");
          }else{
			xmlDomObj.loadXML(xmlString);
	      }
	}else{ // For XML file name/path as String
	   xmlDomObj.load(xmlString);
	}
	return  xmlDomObj;
}

function noImage(el,type){
	switch (type){
		case 'A' : el.src=imageFolderPath+'/noFlightImg.gif'; break;
		case 'H' : el.src=imageFolderPath+'/noHotelimage.gif'; break;
		case 'D' : el.src=imageFolderPath+'/noHotelimagebig.gif'; break;
		case 'C' : el.src=imageFolderPath+'/noCarImg.gif'; break;
		case 'S' : el.src=imageFolderPath+''; break;
		case 'T' : el.src=imageFolderPath+'/noToursntransimage.gif'; break;
		case 'P' : el.src=imageFolderPath+'/noavailable.gif'; break;
	}
	return;
}

function cacheImages(imgArray){
	var imageCacheContainer = obj$("imageCacheContainer");
	if (!imageCacheContainer){
		imageCacheContainer = createObject('div',null,'imageCacheContainer');
		document.body.appendChild(imageCacheContainer)
	}
	hide$(imageCacheContainer);
	var addImage = true;
	var containerImgList = imageCacheContainer.getElementsByTagName('img');
	for (var x=0;x<imgArray.length ;x++ ){
		var img = createObject('img');
		img.src = imgArray[x];
		addImage = true;
		for (var il=0;il<containerImgList.length ;il++ ){
			if (containerImgList[il].src == img.src){
				addImage = false;
				break;
			}
		}
		if (addImage){
			imageCacheContainer.appendChild(img);
		}
	}
}

function createObject(tag, cls, id , value, onclick){
	var el = document.createElement(tag);
	if (cls) {setClass(el,cls);}
	if(id){el.setAttribute('id',id);}
	if (onclick){eval('el.onclick = function(){'+onclick+'};')}
	if(value){
		if (typeof(value) == "string"){
			if (tag.toUpperCase() == 'INPUT'){el.value = value;}else{el.innerHTML = value;}
		}
		if(typeof(value)=='object'){el.appendChild(value);}
	}
	return el;
}

function setClass(element,className){
	element.setAttribute('class',className);
	element.setAttribute('className',className); //<iehack>
}

//COMUTIL JS END////////////////////////////////////////////////////////

//VALIDATOR JS START///////////////////////////////////////////////////////////////////////////////////////


/*******************************************************************************************
	Author					: Atul Phirke
	version					: 1.3 
	created Date			: 15/09/2007
	Last Modified By		: Rohan Kalyanpur
	Last Modified Date		: 12/03/2008
	Explanation				: This Script is used for validations 
	version history         : 1.0 - created                    - Atul Phirke
	                          1.1 - added 'isCreditCardValid'  - Rohan K.
							  1.2 - added 'isValidLength'      - Rohan K.
							  1.3 - added 'isStringAllowSpace' - Rohan K.
 *******************************************************************************************/

var validator=new Validator();

function Validator()
{
	
	this.isEmpty=checkEmpty;
	this.isNumber=checkValidNumber;
	this.isNumberOnly=checkValidNumberOnly;
	this.isPhone=checkValidPhone;
	this.isMobile=checkMobileNo;
	this.isMobileGreaterThanTen=checkMobileNoGreaterThanTen;
	this.isUrl=checkValidUrl;
	this.isEmail=checkValidEmail;
	this.isAlphaNumericString=checkValidAlphaNumericString;
	this.isString=checkValidString;
	this.isStringAllowSpace=checkValidStringAllowSpace;
	this.isIpAddress=checkValidIpAddress;
	this.isImage=checkValidImage;
	this.isDate=checkValidDate;
	this.compareNumber=compareNumber;
	this.compareDate=compareDate;
	this.isCreditCardValid=Mod10;
	this.isValidLength=checkLength;
	this.isValidLengthLessThanOrEqualTo=checkLengthForLessThanOrEqualTo;
	this.isLeapYear=isLeapYear;


	
	/*******************************************************************************************
		Function			:	checkEmpty
		Input				:	input : String 
		Return				:   boolean
		Scope				:   Private
		Description	:	If String is blank then it returns true otherwise returns false
	*******************************************************************************************/
	function checkEmpty(input)
	{
		
		return input==""?true:false;

	}


	/*******************************************************************************************
		Function			:	checkValidNumber
		Input				:	input : String 
		Return				:   boolean
		Scope				:   Private
		Description	:	It checks weather input value is number or not.
									Ex:	12.50 ,1000
	*******************************************************************************************/
	function checkValidNumber(input)
	{
		var pattern=/^([0-9]+([.]?[0-9]+)?){1}$/;
		
		return pattern.test(input);

	}
	
	
	/*******************************************************************************************
		Function			:	checkValidNumberOnly
		Input				:	input : String 
		Return				:   boolean
		Scope				:   Private
		Description	:	It checks weather input value is pure number or not.
									Ex:	1000
	*******************************************************************************************/
	function checkValidNumberOnly(input)
	{
		var pattern=/^[0-9]+$/;
		
		return pattern.test(input);

	}
	
	/*******************************************************************************************
		Function			:	checkValidAlphaNumericString
		Input				:	input : String 
		Return				:   boolean
		Scope				:   Private
		Description	:	It checks weather given input is alphanumeric string or not.
									Ex	:	anmsoft123 or 12323
	*******************************************************************************************/
	
	function checkValidAlphaNumericString(input)
	{
		var pattern=/^[a-zA-Z0-9]+$/;
		
		return pattern.test(input);

	}
	

	/*******************************************************************************************
		Function			:	checkValidPhone
		Input				:	input : String 
		Return				:   boolean
		Scope				:   Private
		Description	:	It checks weather phone number is in specified format.
									Ex	:	+123 
												+(123)4567
												123
												(123)123123
	*******************************************************************************************/
	
	function checkValidPhone(input)
	{
		var pattern=/^[+]?([0-9]+|([(]{1}[0-9]+[)]{1}[0-9]+)|([0-9]+[-]{1}[0-9]+))$/;
		
		return pattern.test(input);

	}

/*******************************************************************************************
		Function			:	checkMobileno
		Input				:	input : String 
		Return				:   boolean
		Scope				:   Private
		Description	:	It checks weather phone number is in specified format.
									Ex	:	
	*******************************************************************************************/
	
	function checkMobileNo(input)
	{
		var pattern=/^[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$/;
		
		return pattern.test(input);

	}

/*******************************************************************************************
		Function			:	isLeapYear
		Input				:	input : String 
		Return				:   boolean
		Scope				:   Private
		Description	:	 It checks weather year is leap or not.
	*******************************************************************************************/
	
	 function isLeapYear (year)
    {
        return (((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? true : false);
    }
	/*******************************************************************************************
		Function			:	checkMobileNoGreaterThanTen
		Input				:	input : String 
		Return				:   boolean
		Scope				:   Private
		Description	:	It checks weather phone number is in specified format greaterThan ten digits.
									Ex	:	
	*******************************************************************************************/
	
	function checkMobileNoGreaterThanTen(input)
	{
		var pattern=/^[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+$/;
		
		return pattern.test(input);

	}
	
	/*******************************************************************************************
		Function			:	checkValidUrl
		Input				:	input : String 
		Return				:   boolean
		Scope				:   Private
		Description	:	 It checks weather input url is in proper format.
									Ex	:	www.ontra.com
		Note				:   other pattern="^((ht|f)tp(s?)\:\/\/|~/|/)?(([a-zA-Z]){3,})([.]{1}[a-zA-Z0-9]{2,}[-]?[a-zA-Z0-9]+)([.]{1}[a-zA-Z0-9]{2,3}){1,2}$";
									For  ftp://www.yahoo.co.in		http://www.ontra.com			 ftps://www.ontra.co.in
	*******************************************************************************************/
	function checkValidUrl(input)
	{
		var pattern=/^(([a-zA-Z]){3,})([.]{1}[a-zA-Z0-9]{2,}[-]?[a-zA-Z0-9]+)([.]{1}[a-zA-Z0-9]{2,3})$/;
		
		return pattern.test(input);

	}
	
	/*******************************************************************************************
		Function			:	checkValidEmail
		Input				:	input : String 
		Return				:   boolean
		Scope				:   Private
		Description	:	 It checks weather email is in proper format.
									Ex	: a@b.com
		
	*******************************************************************************************/
	function checkValidEmail(input)
	{
		var pattern=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
		
		return pattern.test(input);

	}

	
	/*******************************************************************************************
		Function			:	checkValidString
		Input				:	input : String 
		Return				:   boolean
		Scope				:   Private
		Description	:	It checks weather given input is string or not.
									Ex	:	anmsof
	*******************************************************************************************/
	
	function checkValidString(input)
	{
		var pattern=/^[a-zA-Z]+$/;
		
		return pattern.test(input);

	}
	
	/*******************************************************************************************
		Function			:	checkValidStringWithSpace
		Input				:	input : String 
		Return				:   boolean
		Scope				:   Private
		Description	:	It checks weather given input is string with or without space.
									Ex	:	Scott Thomas
	*******************************************************************************************/
    function checkValidStringAllowSpace(input)
	{
		var pattern=/^[a-zA-Z\s]+$/;
		
		return pattern.test(input);

	}

	/*******************************************************************************************
		Function			:	checkValidIpAddress
		Input				:	input : String 
		Return				:   boolean
		Scope				:   Private
		Description	:	It checks weather given input is valid IP Address or not.
									Ex	:	192.168.57.14
	*******************************************************************************************/
	
	function  checkValidIpAddress(input)
	{
		var pattern=/^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})$/;
		
		return pattern.test(input);

	}
	
	
	/*******************************************************************************************
		Function			:	checkValidImage
		Input				:	input : String 
		Return				:   boolean
		Scope				:   Private
		Description	:	It checks weather given input is valid image file.
									Ex	:	extension of file may be jpg, bmp, gif ..........
	*******************************************************************************************/
	function  checkValidImage(input)
	{
		var pattern=/^(jpeg|gif|bmp|dib|jpg|jre|jfif||tif|fiff|png|ico)$/;
		var extension=input.substring(input.lastIndexOf(".")+1);
		return pattern.test(extension);

	}

	

	/*******************************************************************************************
		Function			:	checkValidDate
		Input				:	input : String 
		Return				:   boolean
		Scope				:   Private
		Description	:	It checks weather given input is valid date in mm-dd-yyyy format.
									Ex	:	01-10-2007
	*******************************************************************************************/
	
	function checkValidDate(input)
	{
		
		var pattern       =/^[0-9]{2}[-][0-9]{2}[-][0-9]{4}$/;
		
		return (pattern.test(input) && checkValidDateObject(input));
	}

	/*******************************************************************************************
		Function			:	compareNumber
		Input				:	input1 : String  , input2 : String 
		Return				:   -1 (if input1 < input2) , 0 (if input1 = input2) , 1 (if input1 > input2)
		Scope				:   Private
		Description	:	It compare two numbers.
		Note				:   Pass valid number string . i.e. before calling this function use isNumber Function
	*******************************************************************************************/

	function compareNumber(input1,input2)
	{
			var val1=parseInt(input1);
			var val2=parseInt(input2);

			if(val1 < val2)
				return -1;
			else if(val1>val2)
				return 1; 
			else
				return 0; // for both number are same
	
	}

	
	/*******************************************************************************************
		Function			:	compareDate
		Input				:	input1 : String  , input2 : String 
		Return				:   -1 (if input1 < input2) , 0 (if input1 = input2) , 1 (if input1 > input2)
		Scope				:   Private
		Description	:	It compare two dates.
		Note				:   Pass valid number string . i.e. before calling this function use isDate Function
	*******************************************************************************************/

	function compareDate(input1,input2)
	{
			var date_array = input1.split('-');

			 var day1 =date_array[0];
		
			var month1 =date_array[1];
		
			var year1=date_array[2];
		
			var date_array1 = input2.split('-');

			 var day2 =date_array1[0];
		
			var month2 =date_array1[1];
		
			var year2=date_array1[2];
			

				if(year1<year2)
					return -1;
				else if(year1>year2)
					return 1;
				else
				{
				
					if(month1<month2)
						return -1;
					else if(month1>month2)
						return 1;
					else
					{
						if(day1<day2)
							return -1;
						else if(day1>day2)
							return 1;
						else
							return 0;
					}
			
				}
    }

	
	/*******************************************************************************************
		Function			:	checkValidDateObject
		Input				:	input : String 
		Return				:   boolean
		Scope				:   Private
		Description	:	It checks for valid date.
	*******************************************************************************************/
	 function checkValidDateObject(input)
    {

		
		var date_array = input.split('-');

        var day =date_array[0];
		
        var month =date_array[1];
		
        var year=date_array[2];
		
		
        if (year < 1 || month < 1 || day < 1 || month > 12 || day > getMaxDays (month, year))
        {
            return false;
        }
		
        return true;
    }

	
	/*******************************************************************************************
		Function			:	isLeapYear
		Input				:	input : String 
		Return				:   boolean
		Scope				:   Private
		Description	:	 It checks weather year is leap or not.
	*******************************************************************************************/
	
	 function isLeapYear (year)
    {
        return (((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? true : false);
    }




    /*******************************************************************************************
		Function			:	getMaxDays
		Input				:	month : String , year : String 
		Return				:   int
		Scope				:   Private
		Description	:	 It return maximum daty of the month.
	*******************************************************************************************/
	function getMaxDays (month, year)
    {
		var dayInFeb=isLeapYear (year) ? '29' : '28';
        var daysInMonth = new Array('31', dayInFeb , '31', '30', '31', '30', '31', '31', '30', '31', '30', '31');

        return daysInMonth[month - 1];
	}
	
	
	/*******************************************************************************************
		Function			:	Mod10
		Input				:	ccNumb : String 
		Return				:   boolean
		Scope				:   Private
		Description	        :	Validates the Credit Card No.
		Author              :   David Leppek :: https://www.azcode.com/Mod10
	*******************************************************************************************/
	
	/* 
	Basically, the alorithum takes each digit, from right to left and muliplies each second
	digit by two. If the multiple is two-digits long (i.e.: 6 * 2 = 12) the two digits of
	the multiple are then added together for a new number (1 + 2 = 3). You then add up the 
	string of numbers, both unaltered and new values and get a total sum. This sum is then
	divided by 10 and the remainder should be zero if it is a valid credit card. Hense the
	name Mod 10 or Modulus 10. */
	function Mod10(ccNumb) {  // v2.0
	var valid = "0123456789"  // Valid digits in a credit card number
	var len = ccNumb.length;  // The length of the submitted cc number
	var iCCN = parseInt(ccNumb);  // integer of ccNumb
	var sCCN = ccNumb.toString();  // string of ccNumb
	sCCN = sCCN.replace (/^\s+|\s+$/g,'');  // strip spaces
	var iTotal = 0;  // integer total set at zero
	var bNum = true;  // by default assume it is a number
	var bResult = false;  // by default assume it is NOT a valid cc
	var temp;  // temp variable for parsing string
	var calc;  // used for calculation of each digit
	
	// Determine if the ccNumb is in fact all numbers
	for (var j=0; j<len; j++) {
	  temp = "" + sCCN.substring(j, j+1);
	  if (valid.indexOf(temp) == "-1"){bNum = false;}
	}
	
	// if it is NOT a number, you can either alert to the fact, or just pass a failure
	if(!bNum){
	  /*alert("Not a Number");*/bResult = false;
	}
	
	// Determine if it is the proper length 
	if((len == 0)&&(bResult)){  // nothing, field is blank AND passed above # check
	  bResult = false;
	} else{  // ccNumb is a number and the proper length - let's see if it is a valid card number
	  if(len >= 15){  // 15 or 16 for Amex or V/MC
	    for(var i=len;i>0;i--){  // LOOP throught the digits of the card
	      calc = parseInt(iCCN) % 10;  // right most digit
	      calc = parseInt(calc);  // assure it is an integer
	      iTotal += calc;  // running total of the card number as we loop - Do Nothing to first digit
	      i--;  // decrement the count - move to the next digit in the card
	      iCCN = iCCN / 10;                               // subtracts right most digit from ccNumb
	      calc = parseInt(iCCN) % 10 ;    // NEXT right most digit
	      calc = calc *2;                                 // multiply the digit by two
	      // Instead of some screwy method of converting 16 to a string and then parsing 1 and 6 and then adding them to make 7,
	      // I use a simple switch statement to change the value of calc2 to 7 if 16 is the multiple.
	      switch(calc){
	        case 10: calc = 1; break;       //5*2=10 & 1+0 = 1
	        case 12: calc = 3; break;       //6*2=12 & 1+2 = 3
	        case 14: calc = 5; break;       //7*2=14 & 1+4 = 5
	        case 16: calc = 7; break;       //8*2=16 & 1+6 = 7
	        case 18: calc = 9; break;       //9*2=18 & 1+8 = 9
	        default: calc = calc;           //4*2= 8 &   8 = 8  -same for all lower numbers
	      }                                               
	    iCCN = iCCN / 10;  // subtracts right most digit from ccNum
	    iTotal += calc;  // running total of the card number as we loop
	  }  // END OF LOOP
	  if ((iTotal%10)==0){  // check to see if the sum Mod 10 is zero
	    bResult = true;  // This IS (or could be) a valid credit card number.
	  } else {
	    bResult = false;  // This could NOT be a valid credit card number
	    }
	  }
	}
	// change alert to on-page display or other indication as needed.
	/*if(bResult) {
	  alert("This IS a valid Credit Card Number!");
	}
	if(!bResult){
	  alert("Please Enter A Valid Credit Card Number!");
	}*/
	  return bResult; // Return the results
	}


	/*******************************************************************************************
		Function			:	checkLength
		Input				:	input : String,  validLength : int
		Return				:   boolean
		Scope				:   Private
		Description			:	returns true if the 'input' length 
								is equal to the number 'validLength' 
	*******************************************************************************************/
	function checkLength(input,validLength)
	{
		return (input.length == validLength)?true:false;
	}

	/*******************************************************************************************
		Function			:	checkLengthForLessThanOrEqualTo
		Input				:	input : String,  validLength : int
		Return				:   boolean
		Scope				:   Private
		Description			:	returns true if the 'input' length 
								is less than or equal to the number 'validLength' 
	*******************************************************************************************/
	function checkLengthForLessThanOrEqualTo(input,validLength)
	{
		return (input.length <= validLength)?true:false;
	}


}

//VALIDATOR JS END///////////////////////////////////////////////////////////////////////////////////////


//COMVALIDATOR JS START///////////////////////////////////////////////////////////////////////////////////////

//------------------------------------------ Utility for validator Function -----------------------------------------------//

//-------------Conver given string into date object based on specied input formate-----------------------------
function toDate$(value,format){
	if(!format) format='dd-mm-yyyy';
	var v = value.split('-');
	var dd = mm = yyyy = 0;
	var dt = null;
	var julianYear = 4712;
	if(format == 'dd-mm-yyyy' && v.length >= 3) {
		dd = (v[0] > 31 || v[0] < 1) ? 0 : v[0] ; 
		mm = (v[1] > 12 || v[1] < 1) ? 0 : v[1] ; 
		yyyy = (v[2] > julianYear || v[2] < 0) ? 0 : v[2] ; 
	} else if(format == 'mm-dd-yyyy' && v.length >= 3) {
		dd = (v[1] > 31 || v[0] < 1) ? 0 : v[1] ; 
		mm = (v[0] > 12 || v[0] < 1) ? 0 : v[0] ; 
		yyyy = (v[2] > julianYear || v[2] < 0) ? 0 : v[2] ; 
	} else if(format == 'yyyy-mm-dd' && v.length >= 3) {
		dd = (v[2] > 31 || v[0] < 1) ? 0 : v[2] ; 
		mm = (v[1] > 12 || v[1] < 1) ? 0 : v[1] ; 
		yyyy = (v[0] > julianYear || v[0] < 0) ? 0 : v[0] ; 
	}

	if(dd > 0 && mm > 0 && yyyy > 0 && dd <= maxMonthDays$(mm,yyyy)) { 
		var dt = new Date(yyyy,mm-1,dd) ;
	}

	if(dt && dt=="Invalid Date" || dt=="NaN") 
		dt = null;
	return dt;
}
//---------------to find max days in the gievn month and year---------------------------
function maxMonthDays$(month, year){
	var dayInFeb=isLeap$(year) ? 29 : 28;
	var daysInMonth = new Array(31, dayInFeb , 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	return daysInMonth[month-1];
}
//this function is added to check check in date should not be greater than checkout date
function compareDate(input1,input2)
	{
			var date_array = input1.split('-');

			 var day1 =date_array[0];
		
			var month1 =date_array[1];
		
			var year1=date_array[2];
		
			var date_array1 = input2.split('-');

			 var day2 =date_array1[0];
		
			var month2 =date_array1[1];
		
			var year2=date_array1[2];
			

				if(year1<year2)
					return -1;
				else if(year1>year2)
					return 1;
				else
				{
				
					if(month1<month2)
						return -1;
					else if(month1>month2)
						return 1;
					else
					{
						if(day1<day2)
							return -1;
						else if(day1>day2)
							return 1;
						else
							return 0;
					}
			
				}
    }


// ----------------------------------- Utility Validator ------------------------------------------//
//------------- to check empty string , ignore spaces -----------------------------
function isEmpty$(value){
	return (value.trim() == "" ? true : false)
}
// to check valid integer number only
function isNumer$(value){
	var regExp=/^([0-9]+([.]?[0-9]+)?){1}$/
	return(regExp.test(value))
}
// to check valid integer number only
function isInteger$(value){
	var regExp=/^[0-9]*$/i; 
	return(regExp.test(value))
}
// to check valid leap year
function isLeap$(year){
	return (((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? true : false);
}
//---------- validate value for a valid date based on formate --------------------------------
function isDate$(value, format){
	return (toDate$(value,format)?true:false);
}
//------- to check valid email id-----------------------------------
function isEmail$(value){
	var regExp=/^[A-Za-z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
	return (regExp.test(value))
}

//----------- to check alphabates only-------------------------------
function isAlpha$(value){
	var regExp=/^[a-zA-Z]+$/i;
	return (regExp.test(value))
}

//----------- to check alphabates and number only-------------------------------
function isAlphaNumeric$(value){
	var regExp=/^[a-zA-Z0-9]+$/i;
	return (regExp.test(value))
}

//-------------- to check alphabate, spaces and . only----------------------------
function isAlphaString$(value){
	var regExp=/^[a-zA-Z\s/.]+$/i;
	return (regExp.test(value))
}

//-------------- to check alphabates, number, spaces and . only ----------------------------
function isAlphaNumericString$(value){
	var regExp=/^[a-zA-Z0-9\s/.]+$/i;
	return (regExp.test(value))
}

//----------- to check valid phone numbers-------------------------------
function isPhoneNumber$(value){
	var regExp=/^[0-9\s\+\-\(\)]+$/;
	return (regExp.test(value))
}

//------------ to check cotes ------------------------------
function isCotes$(value){
	var regExp=/["\'""\""]/;
	return (regExp.test(value))
}
//------------to check valid images file extension------------------------------
function isImageFile$(value){
	var regExp=/^[jpeg|gif|bmp|dib|jpg|jre|jfif||tif|fiff|png|ico|svg|swf]+$/;
	var fileType = value.substr(value.lastIndexOf(".")+1).toLowerCase();
	return (regExp.test(fileType))
}
//------ to check valid IP address format------------------------------------
function isIpAddress$(value){
	  var regExp= /\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/
	return (regExp.test(value))
}
function isWebUrl$(value){
//	var regExp = /^((ht|f)tp(s?)\:\/\/|~/|/)?([\w]+:\w+@)?(([a-zA-Z]{1}([\w\-]+\.)+([\w]{2,5}))(:[\d]{1,5})?)?((/?\w+/)+|/?)(\w+\.[\w]{3,4})?([,]\w+)*((\?\w+=\w+)?(&\w+=\w+)*([,]\w*)*)? /
	return (regExp.test(value));
}

//----------------------------------- String Constructor Validator ---------------------------------//

//-----------to check empty , ignore spaces-------------------------------
String.prototype.isEmpty = function(){
	return isEmpty$(this)
}
//------------- to check number and . only-----------------------------
String.prototype.isNumer = function(){
	return isNumer$(this);
}
//--------------to check number only ----------------------------
String.prototype.isInteger = function(){
	return isInteger$(this);
}
//---------------to check leap years---------------------------
String.prototype.isLeap = function(){
	return isLeap$(this);
}
//------------- conver string into date object based on format-----------------------------
String.prototype.isDate = function(format){
	return (isDate$(this,format));
}
//-------------- to check valid email ----------------------------
String.prototype.isEmail = function(){
	return (isEmail$(this));
}
// to check Alphabets only
String.prototype.isAlpha = function(){
	return (isAlpha$(this));
}
// to check Alphabets and numbers only
String.prototype.isAlphaNumeric = function(){
	return (isAlphaNumeric$(this));
}
// to check Alphabets and spaces only
String.prototype.isAlphaString = function(){
	return (isAlphaString$(this));
}
// to check Alphabets, numbers, spaces and . only
String.prototype.isAlphaNumericString = function(){
	return (isAlphaNumericString$(this));
}
// to check valid phone numbers
String.prototype.isPhoneNumber = function(){
	return (isPhoneNumber$(this));
}
// to check cotes
String.prototype.isCotes = function(){
	return (isCotes$(this));
}
// to check image files
String.prototype.isImageFile = function(){
	return (isImageFile$(this));
}
// to check valid ip address 
String.prototype.isIpAddress = function(){
	return (isIpAddress$(this));
}

// to check valid web url 
String.prototype.isWebUrl = function(){
	return (isWebUrl$(this));
}

function commaFormattedNumber(amount, delimiter) {
    if (typeof(delimiter) == 'undefined' || delimiter === null || delimiter == "") {
        delimiter = ',';
    }
	amount=amount+"";
    var a = amount.split('.', 2);
    var d = a[1];
    var i = parseInt(a[0]);
    if (isNaN(i)) {
        return '';
    }
    var minus = '';
    if (i < 0) {
        minus = '-';
    }
    i = Math.abs(i);
    var n = new String(i);
    var a = [];
    while (n.length > 3) {
        var nn = n.substr(n.length - 3);
        a.unshift(nn);
        n = n.substr(0, n.length - 3);
    }
    if (n.length > 0) {
        a.unshift(n);
    }
    n = a.join(delimiter);
    if (d && d.length > 1) {
        amount = n + '.' + d;
    } else {
        amount = n;
    }
    amount = minus + amount;
    return amount;
}
//COMVALIDATOR JS END////////////////////////////////////////////////////////////////////////////////////