function stoperror(){return true;}
// window.onerror=stoperror

//stop quotes
document.onkeypress = function noquotes(e) {
if (document.all) {
//IE
Key = window.event.keyCode;
} else {
Key = e.which;
}
if (Key == 39 || Key == 96 || Key == 34) {
alert("No quotation marks please.");
window.event.keyCode =""; 
}
//pressing enter for skill search
if (document.getElementById("sksrchtext")) {
if (document.getElementById("sksrchtext").value != "" && Key == 13) {
searchskills();
window.event.keyCode =""; 
}
}
}
function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

function stopquotes() {
var strClip = window.clipboardData.getData("Text");
var newClip = "";
if (strClip.indexOf("'") != -1 || strClip.indexOf('"') != -1) {
//replace quotes with null on paste
newClip = replace(strClip,"'","");
newClip = replace(newClip,'"',"");
window.clipboardData.setData("Text",newClip);
alert("Quotation marks have been removed from the pasted text.");
} 
}

window.onbeforeunload = unloadnosave;
function unloadnosave() {
//new job posting
if (document.getElementById("jpnew")) {
if (document.getElementById("jpnsubmitted").value != "Yes") {
var mess = "New Job Posting not saved. All information will be lost.";
return mess;
}
}
//job seeker skills
if (document.getElementById("jsskillspage")) {
if (document.getElementById("jpskillssaved").value != "Yes" || document.sendskills.skillcount.value != document.selectskills.myskills.length) {
var mess = "Skills not saved. All additional skills will be lost.";
return mess;
}
}
//interview questions
if (document.getElementById("intqchanged")) {
if (document.getElementById("intqchanged").value == "Yes") {
var mess = "Interview questions changed but not saved.";
return mess;
}
}
}

function checkjsa() {
//js home - check for job alerts
if (document.getElementById("jsalertscheck")) {
var jsacount = parseInt(document.getElementById("jsacount").value);
var jsaprompted = document.getElementById("jsaprompted").value;
if (jsacount < 1 && jsaprompted != "1") {
var retval = confirm("You have not yet setup any job alerts.\r\nWould you like to do so now?");
if (retval) {window.open("/content/alerts/jsalerts.asp","jsalerts","");}
}
}
}
