﻿

// Perform any global initialization to 
// DOM on page load
$(document).ready(function () {

    // Use UI library to convert a tags with class
    // linkButton into buttons
    $("a.linkButton, input.linkButton, button.linkButton").button();
    $("a.linkButton.popup").button({ icons: { primary: "ui-icon-newwin"} });
    $(".btnDisabled").button({ disabled: true });

    // Auto correct unordered list items
    $("div.footer li:last").css("border-right", "0px");
    $("#block_News ul li:last, ul.results li:last").css("border-bottom", "0px");
    $("li:last, li:last-child").css("border-bottom", "0");
    $("ul.results li.link ul").parent().removeClass("link").addClass("folder");

    // Add gel effect to the google search form
    $("#cse-search-form").addClass("gel_light");

    // Add hover effect for tools list items
    if ($.browser.msie && parseInt($.browser.version, 10) < 7 && parseInt($.browser.version, 10) > 4) {
        // Do not apply tool hover effect for ie6
    } else {
        $("#block_Tools ul.tools li").hover(function () {
            $(this).addClass("hover");
            $(this).find(".toolDesc").addClass("hover");
            $(this).find(".toolName").addClass("hover");
        }, function () {
            $(this).removeClass("hover");
            $(this).find(".toolDesc").removeClass("hover");
            $(this).find(".toolName").removeClass("hover");
        });
    }

    // Add hover effect for news list items
    $("#block_News div.container ul li").hover(function () {
        $(this).addClass("hover");
    }, function () {
        $(this).removeClass("hover");
    });

    // Locate all tool items with 'new' class and append new icon
    $("#block_Tools ul.tools li.new").append("<div class='new'></div>");

});


// Resize an iFrame based on the scrollheight of its content
function resizeIFrame(frameID) {
    var frame = document.getElementById(frameID);
    //alert( $("#" + frameID).contents().height());
    $("#" + frameID).css("height", ($(frame).contents().height() + 10) + "px");    
}                                        


/* Velocity JS Functions */
var site = '';

function popUp(URL) {
    day = new Date();
    id = day.getTime();
    var windowName = "win" + id;        
    window.open(URL, windowName , 'toolbar=1,scrollbars=1,location=1,statusbar=0,menubar=1,resizable=1,width=700,height=700');
}
function UGpopUp(URL) {
    day = new Date();
    id = day.getTime();
    var windowName = "win" + id;        
    window.open(URL, windowName , 'toolbar=1,scrollbars=1,location=1,statusbar=0,menubar=1,resizable=1,width=830,height=630');
}
function newpopUp(URL) {
    day = new Date();
    id = day.getTime();
    var windowName = "win" + id;
    window.open(URL, id , 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1');
}    
function CarbPlanner() {
    var answer = confirm('Please create an account to log in to use the Tools and Forums. \nIf you would like to log-in, please click "OK". \nTo exit, please click "Cancel".' )
	if (answer){		    
		window.location = "http://www.diabetescare.net/forum/login_user.asp";
	}	   
}
/*=======================*/
