/*	keep for code coloring
	<script>
*/
function RedirectToURL(strURL){
	self.location = strURL; 
}

function TargettedSubmit(objForm, objHiddenVarTargetURL, strUrl){
	objHiddenVarTargetURL.value = strUrl;
	objForm.submit();
}

function ValidateAndRedirectToURL(strValidationMessage, strURL){
	if (confirm(strValidationMessage)) {
		RedirectToURL(strURL);
	}
}

function GoBack(intHowFar){
	if (!intHowFar) {
		intHowFar = -1;
	}
	if (intHowFar > 0) {
		intHowFar = -1 * intHowFar
	}
	self.history.go(intHowFar); 
}

function GoForward(intHowFar){
	if (!intHowFar) {
		intHowFar = 1;
	}
	self.history.go(intHowFar); 
}

function CloseCurrentWindow(){
	self.close();
}

function SubmitFormAndCloseCurrentWindow(objForm) {
	objForm.submit();
	CloseCurrentWindow();
}

function CloseCurentWindowAndRefreshParent(strSelectListText, strOriginalParms) {
	if (!self.opener.closed){
		if (strOriginalParms){
			self.opener.location.href = self.opener.location.pathname + strOriginalParms + "&Parm1=" + strSelectListText + '&Time=' + escape(new Date());	
		}
		else{
			self.opener.location.href = self.opener.location.pathname + '?Time=' + escape(new Date()) + "&Parm1=" + strSelectListText;
		}
	}
	CloseCurrentWindow();
}

function refreshParentWindow() {
	if (self.opener) {
		if (!self.opener.closed) {
			var strHREF    = new String(self.opener.location.href);
			var strNewHREF = self.opener.location.href;
				
			if ( strHREF.indexOf("?") > -1 ) {
				strNewHREF += "&";
			}
			else {
				strNewHREF += "?";
			}
			self.opener.location.href = strNewHREF + 'Time=' + escape(new Date());
		}
	}
}

function addQueryStringParam(strQS, strParamName, strParamValue, blnEncodeValue) {
	var strQueryString = new String(strQS);

	if (blnEncodeValue == null) {
		blnEncodeValue = false;
	}
	
	if (strQueryString.indexOf("?") == -1) {
		strQueryString += "?";
	}
	else {
		strQueryString += "&";
	}
	
	strQueryString += strParamName + "="
	if (blnEncodeValue) {
		strParamValue += escape(strParamValue);
	}
	strQueryString += strParamValue;
	
	return strQueryString;
}

//do not use this function. Use setQueryStringParamV2
function setQueryStringParam(strQS, strParamName, strParamValue, blnEncodeValue) {
	strQS = deleteQueryStringParam(strQS, strParamName);
	strQS = addQueryStringParam(strQS, strParamName, strParamValue, blnEncodeValue);
	return strQS;
}

function setQueryStringParamV2(strQS, strParamName, strParamValue, blnEncodeValue) {
    strQS = deleteQueryStringParamV2(strQS, strParamName);
    strQS = addQueryStringParam(strQS, strParamName, strParamValue, blnEncodeValue);
    return strQS;
}

//do not use this function. Use deleteQueryStringParamV2
function deleteQueryStringParam(strQS, strParamName) {
	var strQueryString = new String(strQS);
	var intParamStart  = 0;
	var intParamEnd    = 0;
	
	//is this parameter in query string?
	if (strQueryString.indexOf(strParamName + "=") > -1) {
		//make sure this is the right parameter, it should be preceded with & or ?
		intParamStart = strQueryString.indexOf("?" + strParamName + "=");
		if (intParamStart == -1) {
			intParamStart = strQueryString.indexOf("&" + strParamName + "=");
		}
		if (intParamStart > -1) {
			//the end of paramname=paramvalue group
			//either followed by & or end of query string
			intParamEnd = strQueryString.indexOf("&",intParamStart + 1);
			
			strQueryString = strQueryString.substring(0,intParamStart);
			if (intParamEnd > -1) {
				strQueryString += strQueryString.substring(intParamEnd);
			}
			
		}
	}
	return strQueryString;
}


function deleteQueryStringParamV2(strQS, strParamName) {

    var strQueryString = new String(strQS);
    var intParamStart = 0;
    var intParamEnd = 0;

    //is this parameter in query string?
    if (strQueryString.indexOf(strParamName + "=") > -1) {

        strQueryString = strQueryString.replace("?", "&");

        //make sure this is the right parameter, it should be preceded with & or ?
        intParamStart = strQueryString.indexOf("&" + strParamName + "=");

        if (intParamStart > -1) {
            //the end of paramname=paramvalue group
            //either followed by & or end of query string
            intParamEnd = strQueryString.indexOf("&", intParamStart + 1);

            strTmpString = strQueryString.substring(intParamStart, intParamEnd);
            if (intParamEnd > -1) {
                var re = new RegExp(strTmpString, "gim");
                strQueryString = strQueryString.replace(re, "");
            }
            else {
                strQueryString = strTmpString;
            }

            if (strQueryString.indexOf("?") == -1)
                strQueryString = strQueryString.replace("&", "?");

        }
    }
    return strQueryString;
}


function setRefresh(strQS) {
	return setQueryStringParam(strQS, "Time", new Date(), true);
}

function addQueryStringParam(strQS, strParamName, strParamValue, blnEncodeValue) {
	var strQueryString = new String(strQS);

	if (blnEncodeValue == null) {
		blnEncodeValue = false;
	}
	
	if (strQueryString.indexOf("?") == -1) {
		strQueryString += "?";
	}
	else {
		strQueryString += "&";
	}
	
	strQueryString += strParamName + "="
	if (blnEncodeValue) {
		strParamValue += escape(strParamValue);
	}
	strQueryString += strParamValue;
	
	return strQueryString;
}

function setQueryStringParam(strQS, strParamName, strParamValue, blnEncodeValue) {
	strQS = deleteQueryStringParam(strQS, strParamName);
	strQS = addQueryStringParam(strQS, strParamName, strParamValue, blnEncodeValue);
	return strQS;
}

function deleteQueryStringParam(strQS, strParamName) {
	var strQueryString = new String(strQS);
	var intParamStart  = 0;
	var intParamEnd    = 0;
	
	//is this parameter in query string?
	if (strQueryString.indexOf(strParamName + "=") > -1) {
		//make sure this is the right parameter, it should be preceded with & or ?
		intParamStart = strQueryString.indexOf("?" + strParamName + "=");
		if (intParamStart == -1) {
			intParamStart = strQueryString.indexOf("&" + strParamName + "=");
		}
		if (intParamStart > -1) {
			//the end of paramname=paramvalue group
			//either followed by & or end of query string
			intParamEnd = strQueryString.indexOf("&",intParamStart + 1);
			
			strQueryString = strQueryString.substring(0,intParamStart);
			if (intParamEnd > -1) {
				strQueryString += strQueryString.substring(intParamEnd);
			}
			
		}
	}
	return strQueryString;
}

function setRefresh(strQS) {
	return setQueryStringParam(strQS, "Time", new Date(), true);
}

function RedirectParent(strURL){
    var strOriginal = ""
    if (!self.opener.closed){
        if( strURL != "" ){
            self.opener.location = setQueryStringParam(strURL, "Time", new Date(), true);
        } else {
            self.opener.location = setQueryStringParam( self.opener.location.pathname, "Time", new Date(), true);
        }
    }
}

function CloseCurentWindowAndRedirectFromParent(strURL) {
    RedirectParent(strURL);
	CloseCurrentWindow();
}

function FocusParent(){
    if( !self.opener.closed ){
        self.opener.focus();
    }
}

function closeCurrentWindowAndFocusParent(){
    FocusParent();
    CloseCurrentWindow();       
}

/*********************************************************************
'***    Program: PopupWindow( strURL, strWindow, nWidth, nHeight )
'***    Type: Function
'***
'***    Function: Pops up a new window with displaying the URL passed
'***
'***    Parameters: 
			url - url to use for popup
			width  - window width (optional) default = 40% of document client width
			height - window height (optional) default = 60% of document client height
			windowName - name of window to use (optional) default="new"

'***
'***
'***    Returns: window object representing the newly opened window
'***    Remarks: none
'***
'***    Created by: dimab
'***    Changed by: dimab
'***    Last change: 12/14/08
'*********************************************************************/
function PopupWindow( url, width, height, windowName ) {
	var SE_SUPPORTS_POPUPS = true;
	var Popup = null;
	
   //Default Page
	if (windowName == null)
		windowName = "New";

	//Default Width
	if (width == null)
		width =  screen.availWidth * 0.4;

	//Default Height
	if (height == null)
		height = screen.availHeight * 0.6;


	if (SE_SUPPORTS_POPUPS == (true || null || "")){
	 	Popup = window.open( url, windowName,"toolbar=yes,location=no,directories=yes,status=yes,scrollbars=yes,resizable=yes,width="+width.toString()+",height="+height.toString()+ ",menubar=yes");
	 	Popup.focus();
	}
	else {
	     window.location.href = url;
	}
}


/*****************************************************
	job seeker navigation routines.
	purpose: simplify navigation, isolate logic, shorten html
*****************************************************/
function viewJob( id, acct, keywords ) {
	var KeywordPart = "";
	if (keywords != null)
		KeywordPart = "&keywords=" + escape(keywords);
		
	document.location.href="ViewJob.asp?cjid=" + id + "&accountno=" + acct + KeywordPart ;
}
/* same as add to inbox */
function saveJob( id ) {
	document.location.href="/JobSeeker/AddJobToInbox.asp?jobid=" + id;
}
function sendJob( id ) {
	document.location.href="/JobSeekerx/SendJobForm.asp?jobid=" + id;
}

function applyToJob( id ) {
	document.location.href="/JobSeekerX/ApplyToJobSwitchForm.asp?jobid=" + id;
}
function applyToRedirectJob(jobId){
    var strUrl = "/JobSeekerX/ApplyToJobRedirect.asp?JobID=" + jobId;
    window.open(strUrl);
    
    return false;
}
function viewProfile( id ) {
	document.location.href="/JobSeekerx/ViewCompanyProfile.asp?CompanyProfileID=" + id;
}

function formatLocation(locations, city, state, country) {
	if (locations == 0) {
		document.write("-anywhere-");
	} else if (locations > 1) {
		document.write("-multiple-");
	} else {
		document.write(formatLocationPart(city) + formatLocationPart(state) + country);
	}
}
function formatLocationPart( part, separator ) {
	var re = /\s*-\s*/g; // string with just dash is also empty!

	if (separator == null)
		separator = "-";
	if (part == null || part == "" ||part.replace(re, "") == "")
		return "";
	return part + separator;
}

/*********************************************************************
'***    Function: formatTitle
'***
'***    Parameters: 
        value, text to format
        length - size to conform text 
'***
'***    Returns: void
'***    Remarks: - reformats text to specified length
'***
'***    Created by: niloa
'***    Changed by: 
'***    Last change: 04/01/2009
'*********************************************************************/
function formatTitle(value, length) {
    value = String((value == null) ? "" : value);

    //if no length not specified, print entire length
    if (length == null)
        length = value.length;
    
    //if size is > than val.length, resize text
    if ((length != null) && (value.length > length))
        value = value.slice(0, length) + "...";

    document.write(value);
}

// scrolls to top of page where contentContainer tag exists
function toTop() {
	var content = document.getElementById( "contentContainer" );
	if (content != null)
		content.scrollIntoView();
}

// scrolls to the specified id without causing page to scroll out of view
function scrollTo( id, alignToTop ) {
	if (alignToTop == null)
		alignToTop = false;
		
	var elem = document.getElementById( id );
	if (elem != null)
		elem.scrollIntoView(alignToTop);
}


/*********************************************************************
***	Function: configures back button on pages of type Article
***	
***	Parameters: none
***	
***
***	Remarks: assumes that /ClientScripts/navigationLib.js is included
***
***	Created by: dimab
***	Modified by: sergeyh
***	Last modified: 12/14/2008
***
*********************************************************************/
function configureBackButton( buttonId ) {
	if (buttonId == null)
		buttonId = "Back";

	var btn = document.getElementById(buttonId);
	if (btn != null) {
		if (history.length > getHistoryObjectArrayBase()) {
			btn.value = "Back";
			btn.onclick = function() {history.back();}
		}
		else {
			btn.value = "Close";
			btn.onclick = function() {window.close();}
		}
	}
}

/*********************************************************************
***	Function: needs to configure back button
***    returns 0/1 - for different browsers history starts from 0 or 1
***	
***	Parameters: none
***	
***
***	Remarks: 
***
***	Created by: sergeyh
***	Modified by: sergeyh
***	Last modified: 04/16/2009
***
*********************************************************************/
function getHistoryObjectArrayBase () {
    var strUserAgent = DetectUserAgent(); // getting string value of UserAgent
    var strGeckoBasedUA = "chrome firefox safari"; // Gecko based browsers
    intHistoryStart = 0; // other browsers starts history from 0
    
    isGecko = (strGeckoBasedUA.indexOf(strUserAgent) != -1);
    
    if ( isGecko ) {
        intHistoryStart = 1;
    }
    
    return intHistoryStart;
}

/*********************************************************************
***	Function: detects User Agent Name (needs to configure some scripts)
***
***	
***	Parameters: none
***	
***
***	Remarks: 
***
***	Created by: sergeyh
***	Modified by: sergeyh
***	Last modified: 04/16/2009
***
*********************************************************************/
function DetectUserAgent() {
    var strUserAgent = navigator.userAgent.toLowerCase();

    if (strUserAgent.indexOf("msie") >= 0) return "explorer";
    if (strUserAgent.indexOf("opera") >= 0) return "opera";
    if (strUserAgent.indexOf("firefox") >= 0) return "firefox";
    if (strUserAgent.indexOf("safari") >= 0) return "safari";
    if (strUserAgent.indexOf("chrome") >= 0) return "chrome";
    if (strUserAgent.indexOf("konqueror") >= 0) return "konqueror";

    return "somethingElse";
}

/*********************************************************************
***	Job Search agent navigation functions
***
***	Created by: dimab
***	Modified by: dimab
***	Last modified: 2/1/2009
***
*********************************************************************/
function deleteJobAgent( id ) {
	// use dhtml dialog component
	pageDialog.message = 'Are you sure you want to delete this job search agent?';
	pageDialog.title   = "Confirm delete operation";
	pageDialog.onOk = function () {document.location.href = "/JobSeeker/ChangeJobSearchProfile.asp?agent=Full&actn=DELETE&UserAgentID=" + id};
	pageDialog.onCancel = function () {/* do noting*/};
	pageDialog.modal = true;
	pageDialog.show();
}
// works with both expired and non expired agents
function extendJobAgentExpiration( id, isExpired ) {
	var message = 'Are you sure you want to deactivate this job search agent?';
	var title = 'Confirm deactivate operation';
	if (isExpired) {
		message = 'Are you sure you want to extend expiration date and activate this job search agent?';
		title   = 'Confirm extend operation';
	}

	// use dhtml dialog component
	pageDialog.message = message;
	pageDialog.title   = title;
	pageDialog.onOk = function () {document.location.href = "/JobSeeker/ExtendAgentExpirationDate.asp?UserAgentID=" + id;};
	pageDialog.onCancel = function () {/* do noting*/};
	pageDialog.modal = true;
	pageDialog.show();
}

function editJobAgent( id ) {
	document.location.href = "/JobSeekerX/SearchJobsForm.asp?agent=Full&UserAgentID=" + id + "&actn=change";
}
function showJobAgentHistory( id ) {
	document.location.href = "/JobSeeker/ViewUserAgentRuns.asp?UserAgentID=" + id;
}

function deleteCoverLetter( id ) {
	// use dhtml dialog component
	pageDialog.message = 'Are you sure you want to delete this cover letter?';
	pageDialog.title   = "Confirm delete operation";
	pageDialog.onOk = function () {document.location.href = "/JobSeeker/ChangeCoverLetter.asp?CoverLetterID=" + id + "&actn=delete"};
	pageDialog.onCancel = function () {/* do noting*/};
	pageDialog.modal = true;
	pageDialog.show();
}

function viewCoverLetter( id ) {
	document.location.href="/JobSeeker/ViewCoverLetter.asp?CoverLetterID=" + id;
}
function editCoverLetter( id ) {
	document.location.href="/JobSeeker/ChangeCoverLetterForm.asp?CoverLetterID=" + id + "&actn=change";
}
function copyCoverLetter( id ) {
	document.location.href="/JobSeeker/ChangeCoverLetterForm.asp?BaseCoverLetterID=" + id + "&actn=create";
}

function deleteResume( id ) {
	// use dhtml dialog component
	pageDialog.message = 'Are you sure you want to delete this resume?';
	pageDialog.title   = "Confirm delete operation";
	pageDialog.onOk = function () {document.location.href = "/JobSeeker/ChangeResume.asp?ResumeID=" + id + "&actn=delete"};
	pageDialog.onCancel = function () {/* do noting*/};
	pageDialog.modal = true;
	pageDialog.show();
}

function refreshResume( id ) {
	document.location.href="/JobSeeker/RefreshResume.asp?ResumeID=" + id ;
}

// shows view resume page for JobSeeker using reusme id (encrypted)
function viewResume( encryptedId ) {
	document.location.href="/JobSeeker/ViewResume.asp?ResumeID=" + encodeURIComponent(encryptedId);
}
function viewResumeNoEncode( encryptedId ) {
	document.location.href="/JobSeeker/ViewResume.asp?ResumeID=" + encryptedId;
}
// shows resume by job application
function viewJobApplication( encryptedId ) {
	document.location.href="/JobSeeker/ViewResume.asp?JobApplicationID=" + encodeURIComponent(encryptedId);
}

function forwardResume( id ) {
	document.location.href="/JobSeeker/ForwardResumeForm.asp?ResumeID=" + id;
}

function setResumeAsDefault( id ) {
	document.location.href="/JobSeeker/SetResumeAsDefault.asp?ResumeID=" + id;
}
function showResumeHistory( id ) {
	document.location.href="/JobSeeker/ViewResumeStatistics.asp?ResumeID=" + id ;
}

function jobApplicationsForResume( id ) {
	document.location.href="/JobSeeker/ViewJobApplicationsForResume.asp?ResumeID=" + id ;
}
function jobApplicationsForJob( id ) {
	document.location.href="/JobSeeker/ViewJobApplicationsForJob.asp?JobID=" + id ;
}

function jobApplications() {
	document.location.href="/JobSeeker/ViewJobApplications.asp";
}

function changeResume( id, type ) {
    var strPage = "ChangeResumeShortForm.asp";

    if(type == 1)
        strPage = "ChangeResumeShortForm.asp";
    
    if(type == 2)
        strPage = "ChangeResumeForm.asp";
    
    if(type == 3)
        strPage = "ChangeResumeUploadedForm.asp";
    
	document.location.href="/JobSeeker/" + strPage + "?ResumeID=" + id ;
}

function whoViewedMyResume( id ) {
	self.location.href="/JobSeeker/ViewCompaniesWhoViewedResume.asp?ResumeID=" + id ;;
}
function showResumeOptions( id ){
	self.location.href="/JobSeeker/ViewResumeOptions.asp?ResumeID=" + id ;;
}

function editSearchProfile( id ) {
	document.location.href="/JobSeekerX/SearchJobsForm.asp?ProfileID=" + id + "&actn=change";
}
function deleteSearchProfile( id ) {
	// use dhtml dialog component
	pageDialog.message = 'Are you sure you want to delete this search profile?';
	pageDialog.title   = "Confirm delete operation";
	pageDialog.onOk = function () {document.location.href = "/JobSeeker/ChangeJobSearchProfile.asp?ProfileID=" + id + "&actn=delete"};
	pageDialog.onCancel = function () {/* do noting*/};
	pageDialog.modal = true;
	pageDialog.show();
}

function editInboxItem(id) {
    //this is supported only in IE (fails for: Chrome, Fx, and Opera) 
	//self.navigate("ChangeInboxItemForm.asp?ItemID=" + id + "&actn=change");
	document.location.href="ChangeInboxItemForm.asp?ItemID=" + id + "&actn=change";
}
function executeSearchProfile( id ) {
	document.location.href="/JobSeekerX/SearchJobs.asp?ProfileID=" + id;
}

function createSearchAgent( id, name ) {
	document.location.href="/JobSeekerX/SearchJobsForm.asp?agent=Full&ProfileID=" + id + "&actn=create&JobSearchProfileName=" + name;
}

// assumes encrypted id
function viewJobById( id, iiid ) {
	var strInboxItemPart = (iiid == null ? "" : "&iiid=" + iiid);
	document.location.href="/JobSeekerX/ViewJob.asp?JobID=" + encodeURIComponent( id ) + strInboxItemPart;
}

/*
***	Inbox navigation functions
***
***	Created by: dimab
***	Modified by: rburdan
***	Last modified: 03/06/2009
***
*********************************************************************/
function deleteInboxItem( id ) {
    // use dhtml dialog component
    pageDialog.message = 'Are you sure you want to delete this item from in-box?';
    pageDialog.title   = "Confirm delete operation";
    pageDialog.onOk = function () {document.location.href = "/JobSeeker/ChangeInboxItem.asp?actn=DELETE&ItemID=" + id};
    pageDialog.onCancel = function () {/* do noting*/};
    pageDialog.modal = true;
    pageDialog.show();
}


/*********************************************************************
'***    Function: highlightResItemRow
'***
'***    Parameters: elId - source element id
'***
'***    Returns: void
'***    Remarks: 
        - gets element table row
        - this function assumes that there's a three parent hierarchy
            (e.g. element resides in a p, td, and tr html parent tag)
        - highlights element table row based on id            
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 03/15/2009
'*********************************************************************/
function highlightResItemRow(elId) {

    var objEl = document.getElementById(elId);

    if (objEl != null) {

        //pattern for rows of table with jobSeekerTable class
        var patternExpr = "table.jobSeekerTable tr";
        unhighlightTableRows(patternExpr);

        //table row element is sitting in
        var elRow = objEl.parentNode.parentNode.parentNode;

        //highlight elemennts row
        toggleHighlightRow(elRow, true);
    }
}

/*********************************************************************
'***    Function: toggleHighlightRow(row, blnHighlight)
'***
'***    Parameters: 
        row, current row to highlight
        blnHighlight - true - highlight row, false - reset
'***
'***    Returns: void
'***    Remarks: 
        - toggle highlight/unhiglight table row
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 03/15/2009
'*********************************************************************/
function toggleHighlightRow(row, blnHighlight) {
    if (typeof (blnHighlight) != 'boolean')
        blnHighlight = false;

    // find all rows in table
    if (row != null) {
        // add/remove class "highlight" when mouse enters/leaves
        if (blnHighlight)
            row.className = 'highlight';
        else
            row.className = '';
    }
}

/*********************************************************************
'***    Function: unhighlightTableRows
'***
'***    Parameters: patternExpr - xpath expression
        Example:
        1) all table cells: "table td"
        2) all table rows:  "table tr"
        3) all table rows that have the following css class:
            "table.jsSeekerTable tr"
'***
'***    Returns: void
'***    Remarks: 
    - unhighlight all table rows based on expression
    - default expression un-highlights all table rows
    - uses function defined in prototype.js
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 03/15/2009
'*********************************************************************/
function unhighlightTableRows(patternExpr) {
    if ((patternExpr == null) || (patternExpr == ""))
        patternExpr = 'table tr';

    //returns an array that match pattern expression
    var row, rows = $$(patternExpr);

    for (rowIndex = 0; rowIndex < rows.length; rowIndex++) {
        row = rows[rowIndex];
        toggleHighlightRow(row, false);
    }
}

/*********************************************************************
'***    Function: formatCompanyString
'***
'***    Parameters: 
        value, text to format
        length - size to conform text 
'***
'***    Returns: void
'***    Remarks: -  
'***
'***    Created by:  rburdan
'***    Changed by: 
'***    Last change: 06/10/09
'*********************************************************************/
function formatCompanyString(value, length) {
    value = String((value == null) ? "" : value);
    var strResult = new String("");
    var strShortNameValue =  new String(value);
    
    strShortNameValue = HTMLDecode(strShortNameValue);

    //if no length not specified, print entire length
    if (length == null)
        length = value.length;
    
    //if size is > than val.length, resize text
    if ((length != null) && (value.length > length))
        strShortNameValue = strShortNameValue.slice(0, length) + "...";
  
    var CleanValue = HTMLDecode(value);  
      
    var URLEncodedCleanValue = URLEncode(CleanValue);

    strResult = '<a href="/JobSeekerx/SearchJobs.asp?cnme=' + URLEncodedCleanValue + '"> ' + strShortNameValue + '</a>';

    document.write(strResult);
}

/*********************************************************************
'***    Function:   using RegExp detects if strText contains incorrect symbols 
'***                (usually tinyMCE produces xml mso-styles which are incorrect when sending resume in email)
'***                to avoid this - ask user to use 'Paste from Word' button
'***
'***    Parameters: 
'***		strText - text which is testing
'***    
'***    Returns: True/False
'***    Remarks: returns true if given text contains MSO specific styles.
'***                To get error text use getMSOValidationMessageForTinyMCE function (ValidationLib.js)
'***
'***    Created by: sergeyh
'***    Changed by: sergeyh
'***    Last change: 06/15/2010
'*********************************************************************/
function TextHasMSOfficeStyles(strText){
    if(Trim(strText) == "" || strText == null)
        return false;
    var re = null;
    
    // 0 - do not validate plain text
    // text that has this class, does not need to be validated
    re = /class=\"MsoPlainText\"/gim;
    if (re.test(strText)) return false;
    // 1
    re = /\[if gte mso(.*?)\](.*?)&lt;xml&gt;(.*?)\[endif\]/gim;
    if (re.test(strText)) return true; // no need to continue
    // 2
    re = /\[if supportFields\](.*?)\[endif\]/gim;
    if (re.test(strText)) return true;
    // 3
    re = /\[if gte vml(.*?)[0-9]\](.*?)\[endif\]/gim;
    if (re.test(strText)) return true;
    // 4
    re = /&lt;\/v:formulas&gt;/gim;
    if (re.test(strText)) return true;
    // 5
    re = /@page\sSection/gim;
    if (re.test(strText)) return true;
    // 6
    re = /mso\-(.+)/gim;
    if (re.test(strText)) return true;
    
    return false; // no MS styles found
}

/*********************************************************************
'***    Function:   using RegExp detects if strText contains unsupported html tags
'***    
'***    Parameters: 
'***		strText - text which is testing
'***    
'***    Returns: True/False
'***    Remarks: returns true if text valid
'***
'***    Created by: sergeyh
'***    Changed by: 
'***    Last change: 04/02/2010
'*********************************************************************/
function IsHtmlValidForEntry(strText){
    if(Trim(strText) == "" || strText == null)
        return true;
    
    htmlRegExp = new RegExp('&lt;/?(?:!doctype|html|head|title|link|meta|style|script|body)(.*?)/?&gt;', 'gim');
    
    return !htmlRegExp.test(strText);
}


function viewJobSearchResultBrief(strQS){
    var strUrl = "/JobSeekerX/SearchJobsTable.asp";
    window.location = strUrl + "?" + strQS;
}
function viewJobSearchResultDetailed(strQS){
    var strUrl = "/JobSeekerX/SearchJobs.asp";
    window.location = strUrl + "?" + strQS;
}
// changes job labels to saved of given JobIds
function showInboxedJobs(strIDs){
    var className = null;
    var text      = null;
    var arrIDs = strIDs.split(",");
    
    for(var intIndex = 0; intIndex < arrIDs.length; intIndex++){
        changeSavedJobLabel( arrIDs[intIndex], className, text);
    }
}

function viewSelectedJobs(frmId) {
	frmId = (frmId == null || frmId == "") ? "resultForm" : frmId;
	// get form
	var ResultForm = document.getElementById(frmId);
	if (ResultForm != null) {
		var strOldAction = ResultForm.action;
		ResultForm.action = "/JobSeekerX/ViewSelectedJobs.asp";
		ResultForm.submit();
		ResultForm.action = strOldAction; // set action back (to avoid issues when user goes back)
	}
}
