function mouseOver(widget_id, img) {
    document.getElementById(widget_id).src = img;
}

function mouseOut(widget_id, img) {
    document.getElementById(widget_id).src = img;
}
//Free JavaScript examples on http://www.ScriptBreaker.com
var url = "http://www.UniJobs.co.nz"
var ms = navigator.appVersion.indexOf("MSIE")
var ie5 = (ms > 0) && (parseInt(navigator.appVersion.substring(ms + 5, ms + 7)) >= 5)

function set_as_homepage(othis) {
    if (ie5) {
        othis.style.behavior = 'url(#default#homepage)';
        othis.setHomePage(url);
    }
    else {
        alert("Sorry your browser does not support this script.\n Only Internet Explorer 5 or higher.");
    }
}
var ajax = new Array();

function getCityList(sel) {
    var countryCode = sel.options[sel.selectedIndex].value;
    var campus = document.getElementById('hidcampus').value;
    document.getElementById('campus').options.length = 0; // Empty city select box
    if (countryCode.length > 0) {
        var index = ajax.length;
        ajax[index] = new sack();
        ajax[index].requestFile = 'getCities.php?location=' + countryCode + '&campus=' + campus; // Specifying which file to get
        ajax[index].onCompletion = function () {
            createCities(index)
        }; // Specify function that will be executed after file has been found
        ajax[index].runAJAX(); // Execute AJAX function
    }
}

function createCities(index) {
    var obj = document.getElementById('campus');
    eval(ajax[index].response); // Executing the response from Ajax as Javascript code	
}

function getSubCategoryList(sel) {
    var category = sel.options[sel.selectedIndex].value;
    document.getElementById('campus').options.length = 0; // Empty city select box
    if (category.length > 0) {
        var index = ajax.length;
        ajax[index] = new sack();
        ajax[index].requestFile = 'getSubCategories.php?category=' + category; // Specifying which file to get
        ajax[index].onCompletion = function () {
            createSubCategories(index)
        }; // Specify function that will be executed after file has been found
        ajax[index].runAJAX(); // Execute AJAX function
    }
}

function createSubCategories(index) {
    var obj = document.getElementById('dhtmlgoodies_subcategory');
    eval(ajax[index].response); // Executing the response from Ajax as Javascript code	
}

$(document).ready(function () 
{
    function reset_form() 
	{
        $("#kwords").attr('value', "Enter keyword(s)");
        $("#type").attr('value', "0");
        $("#loc").attr('value', "0");
        $("#worktype").attr('value', "0");
        $("#faculty_select").attr('value', "");
        $("#faculty_discipline_div").hide();
        $("#days").attr('value', "0");
    }

    $("#reset_form").click(function () 
	{
        reset_form();
    });

    if (!jQuery.support.cssFloat) $('#top_menu div').bgiframe();

    $("#type").change(function () 
	{
        var job_category_value = $(this).attr('value');
        if 
		(
			job_category_value == "academic_positions" || 
			job_category_value == "academic_polytech_positions" || 
			job_category_value == "lecturers_and_tutors_jobs" || 
			job_category_value == "other_academic_jobs" || 
			job_category_value == "principal_senior_lecturers_jobs" || 
			job_category_value == "professors_readers_chairs_jobs"
		) 
		{
            show_faculty_disciplines();
        }
        else 
		{
            hide_faculty_disciplines();
        }
    });

    function show_faculty_disciplines() 
	{
        $("#faculty_discipline_div").show();
    }

    function hide_faculty_disciplines() {
        $("#faculty_select").attr('value', '');
        $("#faculty_discipline_div").hide();
    }    
});

/*
sfHover = function () {
    var sfEls = document.getElementById("on_campus_drop_down_menu").getElementsByTagName("LI");
    for (var i = 0; i < sfEls.length; i++) {
        sfEls[i].onmouseover = function () {
            this.className += " sfhover";
        }
        sfEls[i].onmouseout = function () {
            this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

myaccounthover = function () {
    var sfEls = document.getElementById("my_account_drop_down_menu").getElementsByTagName("LI");
    for (var i = 0; i < sfEls.length; i++) {
        sfEls[i].onmouseover = function () {
            this.className += " myaccounthover";
        }
        sfEls[i].onmouseout = function () {
            this.className = this.className.replace(new RegExp(" myaccounthover\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", myaccounthover);*/

//implementation of Do Not Show this window again
var expDate = new Date();
expDate.setTime(expDate.getTime() + 365 * 24 * 60 * 60 * 1000); // one year

function setCookie(isName, isValue, dExpires) {
    document.cookie = isName + "=" + isValue + ";expires=" + dExpires.toGMTString();
}

function getCookie(isName) {
    cookieStr = document.cookie;
    startSlice = cookieStr.indexOf(isName + "=");
    if (startSlice == -1) {
        return false;
    }
    endSlice = cookieStr.indexOf(";", startSlice + 1)
    if (endSlice == -1) {
        endSlice = cookieStr.length;
    }
    isData = cookieStr.substring(startSlice, endSlice);
    isValue = isData.substring(isData.indexOf("=") + 1, isData.length);
    return isValue;
}
/////////////////////////////////////////////////////////////////////////

function popitup(url) {
    if (!getCookie('subscribe_popup')) {
        //find user's screen size
        var screenW = 640,
            screenH = 480;
        if (parseInt(navigator.appVersion) > 3) {
            screenW = screen.width;
            screenH = screen.height;
        }
        else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion) == 3 && navigator.javaEnabled()) {
            var jToolkit = java.awt.Toolkit.getDefaultToolkit();
            var jScreenSize = jToolkit.getScreenSize();
            screenW = jScreenSize.width;
            screenH = jScreenSize.height;
        }
        //document.write("Screen width="+screenW+"<br>"+"Screen height="+screenH);
        var left = (screenW - 475) / 2;
        var top = (screenH - 600) / 2;
        newwindow = window.open(url, 'name', 'height=600,width=475,location=no,menubar=no,scollbars=no,status=no,toolbar=no,resizable=no');
        newwindow.moveTo(left, top);
        if (window.focus) {
            newwindow.focus()
        }
        return false;
    }
}

function open_subscriber_popup(url) {
    //find user's screen size
    var screenW = 640,
        screenH = 480;
    if (parseInt(navigator.appVersion) > 3) {
        screenW = screen.width;
        screenH = screen.height;
    }
    else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion) == 3 && navigator.javaEnabled()) {
        var jToolkit = java.awt.Toolkit.getDefaultToolkit();
        var jScreenSize = jToolkit.getScreenSize();
        screenW = jScreenSize.width;
        screenH = jScreenSize.height;
    }
    //document.write("Screen width="+screenW+"<br>"+"Screen height="+screenH);
    var left = (screenW - 550) / 2;
    var top = (screenH - 700) / 2;
    newwindow = window.open(url, 'name', 'height=700,width=550,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
    newwindow.moveTo(left, top);
    if (window.focus) {
        newwindow.focus()
    }
    return false;
}

function submit_to_popup() {
    name = document.getElementById("name").value;
    email = document.getElementById("email").value;
    return open_subscriber_popup('subscribe_popup.php?name=' + name + '&email=' + email);
}
