﻿// scripts.js - DentalProfessional.com 2010

function writeDate() {
    var today = new Date();
    var year = today.getFullYear();
    document.write(year);
}

function popUp(page) {
    popup_window = window.open(page, 'popup', 'location,menubar,resizable,scrollbars=no,status,toolbar,width=500,height=300');
}

function popUpScrollbar(page) {
    popup_window = window.open(page, 'popup', 'location,menubar,resizable,scrollbars=yes,status,toolbar,width=500,height=300');
}

// IOI for Shopping.aspx
$(document).ready(function () {
    $('.ioiBody').show();
    $('.ioiLink').hide();
    $('.ioiHead').click(function () {
        $(this).toggleClass('ioiExpand');
        $('.ioiBody').slideToggle(400);
        $('.ioiLink').toggle();

        setIoICookie();
    });
});

$(document).ready(function () {
    if (getCookie('dpioiflag') == 'true') {
        $('.ioiBody').hide();
        $('.ioiLink').show();
        $('.ioiHead').toggleClass('ioiExpand');
    }
});

function setIoICookie() {
    if (getCookie('dpioiflag') == 'true') { }
    else {
        var name = 'dpioiflag';
        var val = 'true';
        document.cookie = name + "=" + val;
    }
        
}

function getCookie(check_name) {
    var a_all_cookies = document.cookie.split(';');
    var a_temp_cookie = '';
    var cookie_name = '';
    var cookie_value = '';
    var b_cookie_found = false; 

    for (i = 0; i < a_all_cookies.length; i++) {
        a_temp_cookie = a_all_cookies[i].split('=');
        cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

        if (cookie_name == check_name) {
            b_cookie_found = true;

            if (a_temp_cookie.length > 1) {
                cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));
            }

            return cookie_value;
            break;
        }

        a_temp_cookie = null;
        cookie_name = '';
    }
    if (!b_cookie_found) {
        return null;
    }
}

function deleteCookie(name, path, domain) {
    if (getCookie(name)) document.cookie = name + "=" +
    ((path) ? ";path=" + path : "") +
    ((domain) ? ";domain=" + domain : "") +
    ";expires=Thu, 01-Jan-1969 00:00:01 GMT";
}


$(function () {
    $("#navConditions").hover(function () {
        $(this).addClass('active');

    }, function () {
        $(this).removeClass('active');
    });
});

$(function () {
    $("#navProducts").hover(function () {
        $(this).addClass('active');

    }, function () {
        $(this).removeClass('active');
    });
});

$(function () {
    $("#navMaterials").hover(function () {
        $(this).addClass('active');

    }, function () {
        $(this).removeClass('active');
    });
});


function ClearSearch() {
    $('.search_fld').val('');
    $('.search_fld').focus();
}


function ProConfirm() {
    var name = 'dpprouser';
    var val = 'true';
    document.cookie = name + "=" + val;

    self.parent.tb_remove();
}

function getQueryString(key, def) {
    if (def == null) {
        def = "";
    }

    var search = unescape(location.search);
    if (search == "") {
        return def;
    }

    search = search.substr(1);
    var params = search.split("&");

    for (var i = 0; i < params.length; i++) {
        var pairs = params[i].split("=");
        if (pairs[0] == key) {
            return pairs[1];
        }
    }

    return def;
}
