   // document.onclick = handleclick;
/********cookie set and get***********/
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function checkCookie(){
	if (document.cookie){
		return true;
	}else {
		alert("Cookie is turned off in your web browser. Turn it on to take full advantage of this site, then refresh the page.");
		return false;
	}
	
}
/******************/
function handleclick(e) {
        if (!e) {
            e = window.event;
        }
        if (e != null) {
            var elem = e.srcElement;
            if (elem != null && elem.onclick == null) {
                hideAllHelp();
            }
        }
    }

	var browser = null;
	
	var browserWarningCookie = "browserWarn";
	function displayBrowserWarning(){
		
		// check if cookie set
		if( document.cookie.indexOf(browserWarningCookie + "=")== -1 ){
			alert("This site is not yet fully compatible with your browser\n\nWe recommend either Mozilla/Firefox 2.0+ or Microsoft Internet Explorer 6+");
			setBrowserCookie();
		} else {
			setBrowserCookie();
		}
	}
	
	function setBrowserCookie(){
		var expDate=new Date();
		expDate.setDate(expDate.getDate()+3);
		document.cookie= browserWarningCookie + "=true;" + expDate.toGMTString();
	}
	
	function detectBrowser() {
	
	  var oldOnError = window.onerror;
	  var element = null;
	  
	  var i = 0;
	  var ua = window.navigator.userAgent.toLowerCase();
	  
	  if (ua.indexOf('opera') != -1)
	  {
	    browser="opera";
	    i = ua.indexOf('opera');
	    navigator.family  = 'opera';
	    navigator.org    = 'opera';
	    navigator.version  = parseFloat('0' + ua.substr(i+6), 10);
	    displayBrowserWarning();
	  }
	  else if ((i = ua.indexOf('msie')) != -1)
	  {
	    browser="ie";
	    navigator.org    = 'microsoft';
	    navigator.version  = parseFloat('0' + ua.substr(i+5), 10);
	    
	    if (navigator.version < 7) {
	      navigator.family = 'ie6';
	    } else {
	      navigator.family = 'ie7'
	    } 
	    
	    
	  }
	 /*
		 * else if (typeof(window.controllers) != 'undefined' &&
		 * typeof(window.locationbar) != 'undefined') { i = ua.lastIndexOf('/')
		 * navigator.version = parseFloat('0' + ua.substr(i+1), 10);
		 * navigator.family = 'gecko';
		 * 
		 * if (ua.indexOf('netscape') != -1){ navigator.org = 'netscape';
		 * browser="netscape"; } else { navigator.org = 'mozilla';
		 * browser="mozilla"; } }
		 */
	  else if ((ua.indexOf('mozilla') !=-1) && (ua.indexOf('spoofer')==-1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera')==-1)&& (ua.indexOf('webtv')==-1) && (ua.indexOf('hotjava')==-1))
	  {
	     var is_major = parseFloat(navigator.appVersion);
	    	
	    if (is_major < 4)
	      navigator.version = is_major;
	    else
	    {
	      i = ua.lastIndexOf('/')
	      navigator.version = parseFloat('0' + ua.substr(i+1), 10);
	    }
	    browser="mozilla";
	    navigator.org = 'netscape';
	    navigator.family = 'nn' + parseInt(navigator.appVersion);
	  }
	  else if ((i = ua.indexOf('aol')) != -1 )
	  {
	    // aol
	    browser="aol";
	    navigator.family  = 'aol';
	    navigator.org    = 'aol';
	    navigator.version  = parseFloat('0' + ua.substr(i+4), 10);
	    displayBrowserWarning()
	  } else {
	  	displayBrowserWarning();
	  }
	
	  navigator.DOMCORE1  = (typeof(document.getElementsByTagName) != 'undefined' && typeof(document.createElement) != 'undefined');
	  navigator.DOMCORE2  = (navigator.DOMCORE1 && typeof(document.getElementById) != 'undefined' && typeof(document.createElementNS) != 'undefined');
	  navigator.DOMHTML  = (navigator.DOMCORE1 && typeof(document.getElementById) != 'undefined');
	  navigator.DOMCSS1  = ( (navigator.family == 'gecko') || (navigator.family == 'ie4') );
	
	  navigator.DOMCSS2   = false;
	  if (navigator.DOMCORE1)
	  {
	    element = document.createElement('p');
	    navigator.DOMCSS2 = (typeof(element.style) == 'object');
	  }
	
	  navigator.DOMEVENTS  = (typeof(document.createEvent) != 'undefined');
	  navigator.DOCALL     = (typeof(document.all) != 'undefined');
	
	  window.onerror = oldOnError;
	  
	  // windowAlert(navigator.org + "\n" + navigator.family + "\n" +
		// navigator.version);
	}

	detectBrowser();	
	

	function eraseText(elem){
		elem.value = "";
	}
	
	var eraseCount = 0;
	function eraseTextOnce(elem){
		if(eraseCount>0) return;
		
		elem.value = "";
		eraseCount++;		
	}
	
	function link(str){
		location.href=str;
	}
	
	
	function popMonths(elem,value){
		if(elem!=null && elem.options.length>0) return;
		
		if(value=="resolve" && elem!=null){
			value = elem.value;
		}
		var arr = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
		var arrVal = new Array(0,1,2,3,4,5,6,7,8,9,10,11);
		for(i=0;i<arr.length;i++){
			elem.options[i] = new Option();
			elem.options[i].text = arr[i];
			elem.options[i].value = arrVal[i];
			if(value==arrVal[i])
				elem.selectedIndex=i;
		}
	}
	
	function popYearsFuture(elem,value,addYear){
		if(addYear==null || addYear.length==0){
			return;
		}
		if(elem!=null && elem.options.length>0) return;
		
		if(value=="resolve" && elem!=null){
			value = elem.value;
		}
		var date = new Date();
		var year = (date.getFullYear() + parseInt(addYear));
		var j = 1;
		elem.options[0] = new Option();
			elem.options[0].text = "";
			elem.options[0].value = null;
			
		if(year<200)year=(1900+year);
		for(i=year;i>(year-30);i--){			
			elem.options[j] = new Option();
			elem.options[j].text = i;
			elem.options[j].value = i;
			if(value==i)
				elem.selectedIndex=j;
			j++;
		}
	}
	
	function popTenYearsFuture(elem,value){
		
		if(elem!=null && elem.options.length>0) return;
		
		if(value=="resolve" && elem!=null){
			value = elem.value;
		}
		var date = new Date();
		var year = (date.getFullYear() + 10);
		var j = 1;
		elem.options[0] = new Option();
			elem.options[0].text = "";
			elem.options[0].value = null;
		if(year<200)year=(1900+year);
		for(i=year;i>(year-11);i--){			
			elem.options[j] = new Option();
			elem.options[j].text = i;
			elem.options[j].value = i;
			if(value==i)
				elem.selectedIndex=j;
			j++;
		}
	}
	
	function popYears(elem,value){
		
		if(elem!=null && elem.options.length>0) return;
		
		if(value=="resolve" && elem!=null){
			value = elem.value;
		}
		var date = new Date();
		var year = date.getFullYear();
		var j = 0;
		//elem.options[0] = new Option();
			//elem.options[0].text = "";
			//elem.options[0].value = null;
		if(year<200)year=(1900+year);
		for(i=year;i>(year-80);i--){			
			elem.options[j] = new Option();
			elem.options[j].text = i;
			elem.options[j].value = i;
			if(value==i)
				elem.selectedIndex=j;
			j++;
		}
	}
	
	function popDays(elem,value){
		if(elem!=null && elem.options.length>0) return;
		
		if(value=="resolve" && elem!=null){
			value = elem.value;
		}
		for(i=0;i<=31;i++){
			if(i==0){
				elem.options[i] = new Option();
				elem.options[i].text = "";
				elem.options[i].value = null;
			}
			else {			
				elem.options[i] = new Option();
				elem.options[i].text = (i);
				elem.options[i].value = (i);
				if(value==(i))
					elem.selectedIndex=i;	
			}		
		}
		
	}
	
	function showHelp(id){
		var elem = document.getElementById("help" + id);
		hideAllHelp();
		if(elem!=null){		
			var s = elem.style;			
			s.visibility = "visible";			
		} 		
	}
	
	function hideAllHelp(){
		var tags = document.getElementsByTagName("div");
		if(tags!=null){
			for(i=0;i<tags.length;i++){
				if(tags[i].id.indexOf("help")!=-1){
					tags[i].style.visibility='hidden';
				}
			}
		}
	}
	
	function hideHelp(id){
		var elem = document.getElementById("help" + id);
		if(elem!=null){		
			var s = elem.style;			
			s.visibility='hidden';						
		} 		
	}
	var helpTimerId=null;
	function resetHelpTimeout(duration,id) {
  		if (helpTimerId != null) clearTimeout(helpTimerId);
  		helpTimerId = null;
  		if (duration != null) helpTimerId = setTimeout("hideHelp('" + id + "')",duration);
	}
	
	function openCloseDisplay(id){
		
		var elem = document.getElementById(id);
		if(elem.style.display=='block'){
			elem.style.display='none';
		} else {
			elem.style.display='block';
		}	
	}
	function openCloseDisplayForce(id,action){
		var elem = document.getElementById(id);
		if(action=="open"){
			elem.style.display='block';
		} else {
			elem.style.display='none';
		}
	
	}
	
	function windowAlert(message){
		alert(message);
	}
	
	function rememberMe(elem){
		// do some stuff with cookies here....
	}
	
	
	/*
	 * ****************** JS FORM VALIDATION **********************************
	 * 
	 */
	
	function checkValidEmail2(str){
		
		if(str!=null){
			if(str.indexOf("@")!=-1 && str.length>5 && str.indexOf(".")!=-1){
				return true;
			} else {
				return false;
			}
		}	
	}
	
	function checkValidEmail(id){
		var elem = document.getElementById(id);
		if(elem!=null){
			if(elem.value.indexOf("@")!=-1 && elem.value.length>5 && elem.value.indexOf(".")!=-1){
				return true;
			} else {
				return setErrorBlock("<li>You have entered an invalid email address");
			}
		}	
	}
	
	function isFormEmpty(elem,id,name){
		if(elem==null && id!=null){
			elem = document.getElementById(id);
		}
		if(elem!=null){
			if(elem.value==null || elem.value.length==0){
				if(name!=null){
					alert("The " + name + " field must contain a value");
				} else {
					alert("The field must contain a value");
				}
				elem.focus();
				return false;
			}
		}
		return true;		
	}
	
	function isFormSelected(elem,id,name){
		
		if(elem==null && id!=null){
			elem = document.getElementById(id);
		}
		if(elem!=null){
			if(elem.options.selectedIndex==null || elem.options[elem.options.selectedIndex].value.length==0){
				if(name!=null){
					alert("Please select an option from the " + name + " field before continuing");
				} else {
					alert("Please select an option before continuing");
				}
				elem.focus();
				return false;
			} 			
		}
		return true;
	}
	var futureDateLabelArr;
	var pastDateLabelArr;
	var compareDateLabelArr
	
	function formErrorCheck(f){		
	
		var errorStr = "";
		var elem;
		var formVal;
		var radioErrorStr = "";
		
		// check alert string
		var anotherFunc = document.getElementById("anotherFunc");
		
		if(anotherFunc!=null && anotherFunc.value.length>0){
			if(!eval(anotherFunc.value)){
				return false;
			}
		}
	
		for(i=0;i<formElemArr.length;i++){
			
			elem = f[formElemArr[i]];
			
			if(elem!=null){	
				radioErrorStr = "";				
				if(elem.length>0){	
					var radioName = new Array();
							
					for(j=0;j<elem.length;j++){		
					//alert(elem[j]);
						if(elem[j]!=null && elem[j].type=="radio"){
							radioErrorStr = "<li>" + labelArr[i] + " must be checked";
							if(elem[j].checked==true){
								radioErrorStr="";
								break;
							}
						}
					}
					
				}
				errorStr+=radioErrorStr;
				if(elem.type == "text" || elem.type == "textarea" || elem.type == "button"){
     				formVal = elem.value;
     				formVal = formVal.replace(/\s+/g,"");     				
					if(formVal==null || formVal.length==0){						
						errorStr += "<li>" + labelArr[i] + " is empty";
					} 
				} else if(elem.type=="select-one" && elem.options.selectedIndex!=null && elem.options.selectedIndex >= 0 && elem.options.selectedIndex < elem.options.length){
				
					formVal = elem.options[elem.options.selectedIndex].value;
					if(formVal==null || formVal.length==0 || formVal=="null"){
						errorStr += "<li>" + labelArr[i] + " must be selected";
					}
				} else if(elem.type=="checkbox"){
					if(elem.checked==false){
						errorStr+="<li>" + labelArr[i] + " must be checked";
					}
				} 
				
			}
		}
		
		if(futureDateLabelArr!=null && futureDateLabelArr.length>0){
			errorStr+=testFutureDate();
		}
		if(pastDateLabelArr!=null && pastDateLabelArr.length>0){
		
		}
		if(compareDateLabelArr!=null && compareDateLabelArr.length>0){
			errorStr+=testEndAfterStartDate();
		}
		
		if(errorStr.length>0){
			return setErrorBlock(errorStr);
		}
		
		return true;	
	}
	
	function setErrorBlock(errorStr){
		
		var errorBlk = document.getElementById("jsErrorDiv");
			errorBlk.style.display="block";
			errorBlk.innerHTML="<div class=\"alert-red\">"+errorStr+"</div>";
			
			document.location='#';
			return false;
	}
	
	function makeDate(day,month,year){
		var date = new Date();
			date.setDate(day);
			date.setMonth(month);
			date.setYear(year);
		return date;
	}
	function testEndAfterStartDate(){
		var errorStr = "";
		var start = new Date();
			// today.setDate(today.getDay());
		var end = new Date();
		for(i=0;i<compareDateId.length;i++){
			var x = compareDateId[i].split("-");			
			var day1 = document.getElementById("day" + x[0]);
			var month1 = document.getElementById("month" + x[0]);			
			var year1 = document.getElementById("year" + x[0]);
			var day2 = document.getElementById("day" + x[1]);
			var month2 = document.getElementById("month" + x[1]);
			var year2 = document.getElementById("year" + x[1]);
			if(day1!=null){
				day1 = day1.options[day.selectedIndex].value;
			}
			if(day2!=null){
				day2 = day2.options[day2.selectedIndex].value;
			}
			
			month1 = month1.options[month1.selectedIndex].value;
			year1 = year1.options[year1.selectedIndex].value;
			month2 = month2.options[month2.selectedIndex].value;
			year2 = year2.options[year2.selectedIndex].value;
			if(day1==null){
				day1=2;				
			} 
			if(day2==null){
				day2=2;
			}			
			if(month2!=null && month2.length>0){
				start = makeDate(parseInt(day1),(parseInt(month1)),parseInt(year1));	
				end = makeDate(parseInt(day2),(parseInt(month2)),parseInt(year2));
				if(start.getTime()>end.getTime()){				
					errorStr+= "<li>" +  compareDateLabelArr[i];
				}
			} else {
				
				return "";
			}
			
		}
		return errorStr;
	}
	
	function testFutureDate(){
		var errorStr = "";
		var today = new Date();
			// today.setDate(today.getDay());
		var compare = new Date();
		for(i=0;i<futureDateId.length;i++){
			var day = document.getElementById("day" + futureDateId[i]);
			var month = document.getElementById("month" + futureDateId[i]);
			var year = document.getElementById("year" + futureDateId[i]);
			if(day!=null){
				day = day.options[day.selectedIndex].value;
			}
			month = month.options[month.selectedIndex].value;
			year = year.options[year.selectedIndex].value;
			if(day==null){
				today.setDate(2);
				day = 1;
			}			
			
			compare = makeDate(parseInt(day),(parseInt(month)),parseInt(year));
			if(compare.getTime()>today.getTime()){				
				errorStr+= "<li>" +  futureDateLabelArr[i] + " cannot be in the future";
			}
			
		}
		return errorStr;
	}
	
	function isFormMinLength(elem,id,minLength,name){
		if(elem==null && id!=null){
			elem = document.getElementById(id);
		}
		if(elem!=null){
			if(elem.value!=null && elem.value.length<minLength){
				if(name!=null){
					alert("The " + name + " field must be at least " + minLength + " characters long");
				} else {
					alert("The field must be at least " + minLength + " characters long");
				}
				elem.focus();
				return false;
			}
		}
		return true;		
	}
	
	function setStates(elem, elemId, option){
		var val = elem.options[elem.options.selectedIndex].value;
		var frame = document.getElementById("genericFrame");		
		frame.src="/Utility.do?stage=states&countryId="+val+"&option=" + option + "&elementName=" + elemId;		
	}
	
	function imageSwap(img){
		if(img!=null){
			var imgName = img.src;
			if(imgName.match("_off.gif")!=null){
				imgName = imgName.replace(/\_off\.gif/,"_on.gif");				
			}
			else if(imgName.match("_on.gif")!=null)
				imgName=imgName.replace(/\_on\.gif/,"_off.gif");
			if(imgName.match("-off.png")!=null){
				imgName = imgName.replace(/\-off\.png/,"-on.png");				
			}
			else if(imgName.match("-on.png")!=null)
				imgName=imgName.replace(/\-on\.png/,"-off.png");
				
			img.src=imgName;
		}
	}
	
	function openCloseDiv(elemId){
		
		var elem = document.getElementById(elemId);
		var elemFrame = document.getElementById(elemId + "_iframe");
		if(elem.style.visibility=="visible"){
			elem.style.visibility="hidden";
			if(elemFrame!=null){
				elemFrame.style.visibility="hidden";
			}
		} else {
			
			elem.style.visibility="visible";
			if(elemFrame!=null){
				elemFrame.style.visibility="visible";
			}
		}
	}

	var Cookie = {
  		set: function(name, value, daysToExpire) {
    		var expire = '';
    		if (daysToExpire != undefined) {
      			var d = new Date();
      			d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire)));
      			expire = '; expires=' + d.toGMTString();
    		}
    		document.cookie = name + "=" +escape( value ) + expire;
    	},
  		get: function(name) {
    		var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + '=([^;\\s]*)'));
    		return (cookie ? unescape(cookie[2]) : null);
  		},
  		erase: function(name) {
    		var cookie = Cookie.get(name) || true;
    		Cookie.set(name, '', -1);
    		return cookie;
  		},
  		accept: function() {
    		if (typeof navigator.cookieEnabled == 'boolean') {
      		return navigator.cookieEnabled;
    		}
    		Cookie.set('_test', '1');
    		return (Cookie.erase('_test') === '1');
  		}
  
	};
	
	function fldToLowerCase(field) {
	    if (field != null && field.value != null) {
            field.value = field.value.toLowerCase();
        }
    }

	function fillinFUsername() {
         var username = Cookie.get('idlogikrememberme');
         if (!username) {
             return;
         }
         var usernameElem = document.getElementById("j_username");
         usernameElem.value = username;
         var el = document.getElementById("inputRemember");
         if (el) {
         el.checked=true;
         }
    }
 
 
    function rememberFUsername(form) {
         var el = document.getElementById("inputRemember");
         if (el) {
              if (el.checked) {
                        var username = document.getElementById("j_username").value;
                        Cookie.set('idlogikrememberme', username, 31);
                        return;
               }
          }
                        Cookie.erase('idlogikrememberme');
    }
function isResumeName(s) {
	if (isEmpty(s)) return false;
	 for (i = 0; i < s.length; i++)
     {
        var c = s.charAt(i);
       
        if (!c.match(/[a-z]|[A-Z]|[_]|[-]/)) return false;
     }
	 
	 return true;
}

function isURLStandard(s) {
	if (isEmpty(s)) return false;
	 for (i = 0; i < s.length; i++)
     {
        var c = s.charAt(i);
       
        if (!c.match(/[a-z]|[A-Z]|[0-9]|[_]|[-]/)) return false;
     }
	 
	 return true;
}


function isDigital(s) {
	if (isEmpty(s)) return false;
	if (s.length<4) return false;
	 for (i = 0; i < s.length; i++)
     {
        var c = s.charAt(i);

        if (!c.match(/\d/)) return false;
     }
	 return true;	
}

function isChar(s) {
	if (isEmpty(s)) return false;
	 for (i = 0; i < s.length; i++)
     {
        var c = s.charAt(i);

        if (!c.match(/[a-z]|[A-Z]/)) return false;
     }
	 return true;	
}

function isEmpty(s)
{
   return ((s == null) || (s.length == 0))
}
function printTextArea(elem){
	
	var str="#"+elem;
	
	w=window.open();
	w.document.write($(str).html());
	w.print();
	w.close();

	//window.open(print_text.jsp,"newwin2","width=720,height=600,resizable=yes,scrollbars=yes");
}
function printIframeTextArea(iframeName,elem){
	var elem="#"+elem;
	var iframeName="#"+iframeName;
	
	w=window.open();
	w.document.write($(iframeName).contents().find(elem).html());
	w.print();
	w.close();
	//window.open(print_text.jsp,"newwin2","width=720,height=600,resizable=yes,scrollbars=yes");
}

/******************tinymce stuff*******************/
function postTinyMCEInit() {
	  setTimeout(jspellInit,200);	 
}
function startTinyMCE(){
	startTinyMCEDefault("textareas");
}
function startTinyMCENone(){
	startTinyMCEDefault("none");
}
function startTinyMCEExact(elems){
	if (window.navigator.userAgent.toLowerCase().indexOf("safari")!=-1){
		tinyMCE.init({		
				mode : "exact",
				elements : elems,

				theme : "advanced",
				plugins : "safari,iespell,inlinepopups,paste,wordcount",

				// Theme options
				theme_advanced_buttons1 : "bold,italic,underline,|,bullist,numlist,|,removeformat,cleanup,|,pasteword",
			    theme_advanced_buttons2 :"",
				theme_advanced_buttons3 :"",
				theme_advanced_buttons4 :"",
			    //location and resize

				theme_advanced_toolbar_location : "top",
				theme_advanced_toolbar_align : "left",

				//validtion and filter
			
			    remove_trailing_nbsp : true,
			    cleanup_on_startup : true,
			    convert_urls : false,
			    valid_elements : '+a[href|target:_blank],-strong/-b,-em/-i,-u,+p,-ol,-ul,-li,br,-div,-span[class]',
			   theme_advanced_resize_horizontal : false,
			  theme_advanced_statusbar_location : "bottom",
		        theme_advanced_resizing : true,
		       theme_advanced_path : false
				});	
		     }else {
		    	 tinyMCE.init({		
		    	    mode : "exact",
					elements : elems,
		  			theme : "advanced",
		  			plugins : "safari,iespell,inlinepopups,paste,wordcount",

		  			// Theme options
		  			theme_advanced_buttons1 : "bold,italic,underline,|,bullist,numlist,|,removeformat,cleanup,|,pasteword",
		  		    theme_advanced_buttons2 :"",
		  			theme_advanced_buttons3 :"",
		  			theme_advanced_buttons4 :"",
		  		    //location and resize

		  			theme_advanced_toolbar_location : "top",
		  			theme_advanced_toolbar_align : "left",

		  			//validtion and filter
		  		
		 		    remove_trailing_nbsp : true,
		 		    cleanup_on_startup : true,
		 		    convert_urls : false,
		 		    valid_elements : '+a[href|target:_blank],-strong/-b,-em/-i,-u,+p,-ol,-ul,-li,br,-div,-span[class]',
		 		    theme_advanced_resize_horizontal : false,
		 		    theme_advanced_statusbar_location : "bottom",
		 	        theme_advanced_resizing : true,
		 	        theme_advanced_path : false,

		 		    oninit : "postTinyMCEInit"
		  			});	
		    	
		     }
}
function startTinyMCEDefault(startMode){	   
if (window.navigator.userAgent.toLowerCase().indexOf("safari")!=-1){
	tinyMCE.init({		
			mode : startMode,
			theme : "advanced",
			plugins : "safari,iespell,inlinepopups,paste,wordcount",

			// Theme options
			theme_advanced_buttons1 : "bold,italic,underline,|,bullist,numlist,|,removeformat,cleanup,|,pasteword",
		    theme_advanced_buttons2 :"",
			theme_advanced_buttons3 :"",
			theme_advanced_buttons4 :"",
		    //location and resize

			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",

			//validtion and filter
		
		    remove_trailing_nbsp : true,
		    cleanup_on_startup : true,
		    convert_urls : false,
		    valid_elements : '+a[href|target:_blank],-strong/-b,-em/-i,-u,+p,-ol,-ul,-li,br,-div,-span[class]',
		   theme_advanced_resize_horizontal : false,
		  theme_advanced_statusbar_location : "bottom",
	        theme_advanced_resizing : true,
	       theme_advanced_path : false
			});	
	     }else {
	    	 tinyMCE.init({		
	  			mode : startMode,
	  			theme : "advanced",
	  			plugins : "safari,iespell,inlinepopups,paste,wordcount",

	  			// Theme options
	  			theme_advanced_buttons1 : "bold,italic,underline,|,bullist,numlist,|,removeformat,cleanup,|,pasteword",
	  		    theme_advanced_buttons2 :"",
	  			theme_advanced_buttons3 :"",
	  			theme_advanced_buttons4 :"",
	  		    //location and resize

	  			theme_advanced_toolbar_location : "top",
	  			theme_advanced_toolbar_align : "left",

	  			//validtion and filter
	  		
	 		    remove_trailing_nbsp : true,
	 		    cleanup_on_startup : true,
	 		    convert_urls : false,
	 		    valid_elements : '+a[href|target:_blank],-strong/-b,-em/-i,-u,+p,-ol,-ul,-li,br,-div,-span[class]',
	 		    theme_advanced_resize_horizontal : false,
	 		    theme_advanced_statusbar_location : "bottom",
	 	        theme_advanced_resizing : true,
	 	        theme_advanced_path : false,

	 		    oninit : "postTinyMCEInit"
	  			});	
	    	
	     }
	 
}

function cleanUpTextBoxes(elem){
	var textAreaArray = new Array(elem);
	var tMce = null;
	for(i=0;i<textAreaArray.length;i++){
		if(tinyMCE.getInstanceById(textAreaArray[i])!=null){
			tMce = tinyMCE.getInstanceById(textAreaArray[i]);
		}
	

	if(tMce!=null){		
		
		tinyMCE.triggerSave();
		jspellDetach();
		/**tinyMCE.activeEditor.dom.removeClass(tinyMCE.activeEditor.dom.select('span'), 'j6');
		tinyMCE.activeEditor.dom.removeClass(tinyMCE.activeEditor.dom.select('span'), 'j5');
		tinyMCE.activeEditor.dom.removeClass(tinyMCE.activeEditor.dom.select('span'), 'j4');	
		tinyMCE.activeEditor.dom.removeClass(tinyMCE.activeEditor.dom.select('span'), 'j3');	
		tinyMCE.activeEditor.dom.removeClass(tinyMCE.activeEditor.dom.select('span'), 'j2');
		tinyMCE.activeEditor.dom.removeClass(tinyMCE.activeEditor.dom.select('span'), 'j1');
		**/
		tinyMCE.execCommand("mceCleanup",true);
		

	}
	}
}

/************************************/

function closeAllDivs(){
	var tagArr = document.getElementsByTagName("div");
	for(i=0;i<tagArr.length;i++){
		var divName = tagArr[i].id.substring(0,4);
		if(divName=="edit" || divName =="stat" || divName=="priv"){				
			tagArr[i].style.visibility = "hidden";
			var ifr = document.getElementById(tagArr[i].id + "_iframe");
			if(ifr!=null){
				ifr.style.visibility="hidden";
			}	
		}			
	}		
}

function grenameResume(personResumeId,newName){
	var newName=newName.replace(/\s/g,"-");
	if (isResumeName(newName)){
	$.get("/registered/resumeList.do", { stage: "rename",personResumeId:personResumeId,newName:newName},
			function(data)
			{  if(data.indexOf('0')!=-1) {
		    	   alert("You have used an invalid character");
		       }else if(data.indexOf('-1')!=-1) {
		    	   alert("You have duplicate resume names. Please choose another name");
		       }else if (data.indexOf('1')!=-1){
			       document.getElementById("resumeName"+personResumeId+"Div").innerHTML=newName;
		       }
			}
	);
	}else {
		alert("You have used an invalid character");
	}
}