function openWindow(url) {
    var win = window.open(url,'',"width=350,height=220,scrollbars");
    if (win.focus != null) win.focus();
}
function openWin(url) {
    var win = window.open(url,'',"resizable,scrollbars,status,toolbar,menubar");
    if (win.focus != null) win.focus();
}
function openPop(url) {
    var win = window.open(url,'',"width=470,height=500,scrollbars");
    if (win.focus != null) win.focus();
}
function openHelp(url) {
    var win = window.open(url,'',"width=450,height=300,scrollbars");
    if (win.focus != null) win.focus();
}
function openNote(url) {
    var win = window.open(url,'',"width=450,height=300,scrollbars");
    if (win.focus != null) win.focus();
}
function cookieVal(cookieName, cookieString) {
    var startLoc = cookieString.indexOf(cookieName);
    if (startLoc == -1) return(""); // No such cookie
    var sepLoc = cookieString.indexOf("=", startLoc);
    var endLoc = cookieString.indexOf(";", startLoc);
    if (endLoc == -1) endLoc = cookieString.length;
    return(cookieString.substring(sepLoc+1, endLoc));
}
function insertAPID(form) {
    if (form == 'ordForm')  { var apname = document.ordForm.apname;   var adid = document.ordForm.adid;  }
    if (form == 'reqForm')  { var apname = document.reqForm.apname;   var adid = document.reqForm.adid;  }
    if (form == 'RFQForm')  { var apname = document.RFQForm.apname;   var adid = document.RFQForm.adid;  }
    if (form == 'bookForm') { var apname = document.bookForm.apname;  var adid = document.bookForm.adid; }
    var cookies = document.cookie;
    apname.value = cookieVal("MFA-APNAME", cookies);
    adid.value = cookieVal("MFA-ADID", cookies);
}
var imageSupported = (document["images"] != null);
if (imageSupported) {
    imageFiles = new Array("champagne","meetup","solution","work","present","adeal","time","headline");
    imageObjects = new Array(imageFiles.length);
    for (var i=0; i<imageFiles.length; i++) {
        imageObjects[i] = new Image(108, 133);
        imageObjects[i].src = imagePath(imageFiles[i]);
    }
}
function imagePath(imageName) {
    return("portal/images/" + imageName + "2.gif");
}
function setImage(image) {
    document.images['Card'].src = image;
}
function showSlide(task) {
    var origImage = document.images['Card'].src;
    for (var i=0; i<imageFiles.length; i++) {
        var test = origImage.indexOf(imageFiles[i]);
        if (test != -1) { 
            if (task == 'prev') {
                if (i == 0) n=7;
                else n=i-1;
            }
            else {
                if (i == 7) n=0; 
                else n=i+1;
            }
            var newImage = imagePath(imageFiles[n]);
            setImage(newImage);
        } 
    }
}

function isInt(string) {
    var val = parseInt(string);
    return(val > 0);
}
function checkReg() {
    var biz = document.reqForm.business;
    if (biz.value == ""||biz.value == null) { alert("Please Identify Your Company!"); biz.focus(); return(false); } 
    var cnt = document.reqForm.country;
    if (cnt.value == "Select Country") { alert("Please Select Your Country!"); return(false); } 
    var name = document.reqForm.name; 
    if (name.value == ""||name.value == null) { alert("Name Missing!"); name.focus();  return(false); } 
    else { if (isInt(name.value)) { alert("Invalid Name!"); name.focus();  return(false); } }
    var email = document.reqForm.email;
    if (email.value == ""||email.value == null) { alert("Email Missing!"); email.focus(); return(false); } 
    else {
        re = /^[a-z0-9!#$&'*+=?^_`{|}~-]+(\.[a-z0-9!#$&'*+=?^_`{|}~-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/i;
        if (!re.test(email.value)) { alert("Please provide a valid e-mail address!"); email.focus(); return(false); }
    }
    var url = document.reqForm.url;
    if (url.value == "http://"||url.value == null) { alert("This registration gives you the right to install our software on a single Web site. Please identify the URL!"); url.focus();  return(false); } 
    else { if (isInt(url.value)) { alert("Invalid URL!"); url.focus();  return(false); } }
    return(true);
}
function checkSub() {
    var first = document.gazette.firstname;
    if (first.value == "") { alert("Please enter your First Name!"); first.focus();  return(false); }
    else { if (first.value == "First Name") { alert("Please enter your First Name!");  first.focus();  return(false); } }
    var last = document.gazette.lastname;
    if (last.value == "") { alert("Please enter your Family or Last Name!");  last.focus();  return(false); }
    else { if (last.value == "Last Name") { alert("Please enter your Family or Last Name!"); last.focus();  return(false); } }
    var mail = document.gazette.email;
    if (mail.value == "") { alert("Please provide your contact email address!"); mail.focus();  return(false); }
    else { 
        if (mail.value == "Email Address") { alert("Please provide your contact email address!"); mail.focus(); return(false); } 
        else {
            re = /^[a-z0-9!#$&'*+=?^_`{|}~-]+(\.[a-z0-9!#$&'*+=?^_`{|}~-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/i;
            if (!re.test(mail.value)) { alert("Please provide a valid e-mail address!"); mail.focus(); return(false); }
        }
    }
    return(true);
}
function addURL() {
    var name = document.addURL.name;
    if (name.value == "") { alert("Name Missing!"); name.focus(); return(false); } 
    else { if (isInt(name.value)) { alert("Invalid Name!"); name.focus(); return(false); } }
    var email = document.addURL.email;
    if (email.value == "") { alert("Email Missing!"); email.focus(); return(false); } 
    else { 
        re = /^[a-z0-9!#$&'*+=?^_`{|}~-]+(\.[a-z0-9!#$&'*+=?^_`{|}~-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/i;
        if (!re.test(email.value)) { alert("Please provide a valid e-mail address!"); email.focus(); return(false); }
    }
    var url = document.addURL.url;
    if (url.value == "http://") { alert("Please identify your shop's URL!"); url.focus(); return(false); }
    else { if (isInt(url.value)) { alert("Invalid URL!"); url.focus(); return(false); } }
    var title = document.addURL.title;
    if (title.value == "") { alert("Please give a catchy slogan to your shop!"); title.focus(); return(false); }
    else { if (isInt(title.value)) { alert("Slogan that starts with a number will not be accepted!"); title.focus(); return(false); } }
    var desc = document.addURL.desc;
    if (desc.value == "") { alert("Please describe your business in less than 220 characters!"); desc.focus(); return(false); }
    else { 
        if (isInt(desc.value)) { alert("Invalid Description! Please do not start a sentence with numbers!"); desc.focus(); return(false); } 
        else { if (desc.value.length > 220) { alert("Description too long! Please describe your business in less than 220 characters!");  desc.focus();  return(false); } }
    }
    var key = document.addURL.key;
    if (key.value == "") { alert("Please list the keywords that best describe your shop!"); key.focus(); return(false); }
    else { if (isInt(key.value)) { alert("Invalid Keywords!"); key.focus(); return(false); } }
    var cnt = document.addURL.country;
    if (cnt.value == "") { alert("Please select the country where you want to be listed!"); cnt.focus(); return(false); } 
    return(true);
}

function checkRFQ() {
    var name = document.RFQForm.name;
    if (name.value == "") { alert("Name missing!"); name.focus(); return(false); } 
    else { if (isInt(name.value)) { alert("Invalid Name!"); name.focus(); return(false); } }
    var mail = document.RFQForm.mail;
    if (mail.value == "") { alert("Please provide your email address!");  mail.focus(); return(false); } 
    else {
        re = /^[a-z0-9!#$&'*+=?^_`{|}~-]+(\.[a-z0-9!#$&'*+=?^_`{|}~-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/i;
        if (!re.test(mail.value)) { alert("Please provide a valid e-mail address!"); mail.focus(); return(false); }
    }
    var tel = document.RFQForm.tel;
    if (tel.value == "") { alert("Please enter your contact number!"); tel.focus(); return(false); }
    var biz = document.RFQForm.biz;
    if (biz.value == "") { alert("Please identify your business!");  biz.focus(); return(false); } 
    var addr = document.RFQForm.addr;
    if (addr.value == "") { alert("Please enter your contact address!"); addr.focus(); return(false); }
    var city = document.RFQForm.city;
    if (city.value == "") { alert("Please enter your city!");  city.focus(); return(false); } 
    var state = document.RFQForm.state;
    if (state.value == "") { alert("Please enter your state!");  state.focus(); return(false); }
    var zip = document.RFQForm.zip;
    if (zip.value == "") { alert("Please enter your zip code!");  zip.focus(); return(false); } 
    var desc = document.RFQForm.desc;
    if (desc.value == "") { alert("Please describe nature of business!");  desc.focus();  return(false); } 
    var url = document.RFQForm.url;
    if (url.value == "") { alert("Please identify your Web domain!");  url.focus();  return(false); }    
    var spec = document.RFQForm.spec;
    if (spec.value == "") { alert("Please specify your job requirements!");  spec.focus(); return(false); } 
    return(true);
}

function statusHandler(destid, url) {
    this.targetID = destid;
    this.targetElement = document.getElementById(destid);
    this.loader = new net.ContentLoader(this, url, "GET");
    this.loader.sendRequest();
}

statusHandler.prototype.notify = function(request) {
    var data = request.responseText;
    if(data == null) { return; }
    this.targetElement.innerHTML = data;
}

statusHandler.prototype.notifyError = function(request) { }

function checkForm() {
    var domain = document.ordForm.domain;
    if (domain.value == "") { alert("Please specify your domain name!");  domain.focus();  return(false); } 
    else { if (isInt(domain.value)) { alert("Invalid Domain Name!");  domain.focus();  return(false); } }
    var name = document.ordForm.name;
    if (name.value == "") { alert("Please provide your full name, including family name!");  name.focus(); return(false); } 
    else { if (isInt(name.value)) { alert("Invalid Name!");  name.focus();  return(false); } }
    var add1 = document.ordForm.add1;
    if (add1.value == "") { alert("Please provide your mailing address!");  add1.focus();  return(false); } 
    var city = document.ordForm.city;
    if (city.value == "") { alert("Please identify the city of your mailing address!");  city.focus();  return(false); }
    else { if (isInt(city.value)) { alert("Invalid City!");  city.focus();  return(false); } } 
    var phone = document.ordForm.phone;
    if (phone.value == "") { alert("Please provide your contact phone number!");  phone.focus();  return(false); }
    var mail = document.ordForm.mail;
    if (mail.value == "") { alert("Please provide your email address!");  mail.focus();  return(false); } 
    else {
        re = /^[a-z0-9!#$&'*+=?^_`{|}~-]+(\.[a-z0-9!#$&'*+=?^_`{|}~-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/i;
        if (!re.test(mail.value)) { alert("Please provide a valid e-mail address!");  mail.focus();  return(false); }
    }
    var yes = document.ordForm.yes;
    if (yes.value == "No") { alert("Please select 'Yes' to confirm that you've read and agreed to abide by our Terms of Use!");  yes.focus();  return(false); } 
    return(true);
}

function checkData() {
    var name = document.trial.name;
    if (name.value == "") { alert("Please give your name!");  name.focus();  return(false); } 
    else { if (isInt(name.value)) { alert("Invalid Name!");  name.focus();  return(false); } }
    var mail = document.trial.mail;
    if (mail.value == "") { alert("Please provide your contact email address!");  mail.focus();  return(false); } 
    else {
        re = /^[a-z0-9!#$&'*+=?^_`{|}~-]+(\.[a-z0-9!#$&'*+=?^_`{|}~-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/i;
        if (!re.test(mail.value)) { alert("Please provide a valid e-mail address!");  mail.focus();  return(false); }
    }
    var ident = document.trial.ident;
    if (ident.value == "") { alert("Please enter your mother's maiden name!");  ident.focus();  return(false); }
    else { if (isInt(ident.value)) { alert("Invalid Name!");  ident.focus();  return(false); } }
    return(true);
}

function validForm() {
    var first = document.contest.first;
    if (first.value == "") { alert("Please give your first name!");  first.focus();  return(false); } 
    else { if (isInt(first.value)) { alert("Invalid first name!");  first.focus();  return(false); } }
    var last = document.contest.last;
    if (last.value == "") { alert("Please give your last name!");  last.focus();  return(false); } 
    else { if (isInt(last.value)) { alert("Invalid last name!");  last.focus();  return(false); } }
    var mail = document.contest.mail;
    if (mail.value == "") { alert("Please provide your contact email address!");  mail.focus();  return(false); } 
    else {
        re = /^[a-z0-9!#$&'*+=?^_`{|}~-]+(\.[a-z0-9!#$&'*+=?^_`{|}~-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/i;
        if (!re.test(mail.value)) { alert("Please provide a valid e-mail address!");  mail.focus();  return(false); }
    }
    return(true);
}

function setbgcol(e, c) {
    while(e.tagName!='TR') { e = e.parentNode; }
    var children = e.childNodes;
    var tdc = 0;
    for (var i = 0; i < children.length; i++) {
        var child = children.item(i);
        if (child.tagName == "TD") { tdc++; }
        if (tdc >= 1) { child.bgColor = c; }
    }
    e.bgColor = c;
}

function hll(l) {
    setbgcol(document.getElementById('l1'), '#DBEDFF');
    setbgcol(document.getElementById('l2'), '#DBEDFF');
    setbgcol(l, '#B4D6F9');
    l.checked = true;
    insertAPID('ordForm');
    var destid="valid";
    var url = "https://www.clickitpro.com/cgi-bin/ushop/account.pl?validate_input&EVS8FIVNYGT";
    var handler = new statusHandler(destid, url);
}

function hlh(h, p) {
    setbgcol(document.getElementById('h1'), '#DBEDFF'); document.getElementById('p1').style.fontWeight = 'normal'; document.getElementById('p1').style.visibility = 'hidden';
    setbgcol(document.getElementById('h2'), '#DBEDFF'); document.getElementById('p2').style.fontWeight = 'normal'; document.getElementById('p2').style.visibility = 'hidden'; 
    setbgcol(document.getElementById('h3'), '#DBEDFF'); document.getElementById('p3').style.fontWeight = 'normal'; document.getElementById('p3').style.visibility = 'hidden'; 
    setbgcol(document.getElementById('h4'), '#DBEDFF'); document.getElementById('p4').style.fontWeight = 'normal'; document.getElementById('p4').style.visibility = 'hidden'; 
    setbgcol(h, '#B4D6F9'); h.style.fontWeight = 'bold'; p.style.fontWeight = 'bold'; p.style.visibility = 'visible'; 
    h.checked = true;
}

