﻿
function searchTerm() {
            var val = document.getElementById('inpSearch').value;
            window.parent.location = "http://sheridan.summon.serialssolutions.com/search?s.q=" + val;
            return false;
        }
        
function open_win(url_add)
{
    window.open(url_add,'welcome','width=300,height=200,menubar=yes,status=yes, location=yes,toolbar=yes,scrollbars=yes');
}

function SearchList()
    {
        var l =  document.getElementById('listbox');
        var tb = document.getElementById('ctl11_searchBox');
        
        if (tb.value == '')
            tb = document.getElementById('tbTitle'); //
            
        var sVal = tb.value;
        l.innerHTML = '';
        if(sVal == "" || sVal.length < 4)
        {
            l.style.display = 'none';
        }
        else{
            for (var i=0; i < prog_title.length; i++)
            {
                if (prog_title[i].split(',')[0].toLowerCase().search(sVal.toLowerCase()) != -1)
                {
                    l.innerHTML += "<a href='"+ prog_title[i].split(',')[1] +"' >"+ prog_title[i].split(',')[0] +"</a><br />";
                    l.style.display = 'block';
                    l.setAttribute("class", "divShow");
                    l.setAttribute("className", "divShow"); 
                }
            }
        }
        if (l.innerHTML == '')
            l.style.display = 'none';
    }
    function ClearSelection(lb)
    {
        l.innerHTML = '';
    }     
    
    function imageShow(divId) {
    var imgM = document.getElementById('imgMain');
    if (divId == '1') {
        imgM.src = '~/media/Health%20Services/rotator2_e_bulletin.ashx';
//        imgM.onclick = Function("openWin('http://www.google.com/')");
    }
    else if (divId == '2') {
        imgM.src = '~/media/Health%20Services/rotator1_nutrition_tips.ashx';
//        imgM.onclick = Function("openWin('http://www.yahoo.com/')");
    }
    else if (divId == '3') {
        imgM.src = '~/media/Health%20Services/rotator3_meet_our_staff.ashx';
//        imgM.onclick = Function("openWin('http://www.bing.com/')");
    }
    return false;
}

function openWin(pageURL) 
{
    window.open(pageURL);
}

///// HEALTH SERVICES PAGE //////
$(document).ready(function() {
    
    var querystring = window.location.search.substring(1);
    if (querystring != "")
    {
        var qaVariable = querystring.split('&');
        if (qaVariable[0].split('=')[0] == 'iframe_src' && qaVariable[0].split('=')[1] == 'y')
        {
            var ifSrc = "http://cfprod.sheridaninstitute.ca/coned/infosession_reg/index.cfm?EVENT_ID="+qaVariable[1].split('=')[1];
            $("#theiframe").attr('src',ifSrc);
        }
    }
    
    if ($(".hs_leftContent").length > 0 )
    {
        $(".highlight_box").addClass("highlight_box_white");
        $(".onefull").parents('div.sub_padding clearfix').removeClass("sub_padding clearfix");
    }

    if ($(".remove_grey_bg").length > 0 )
    {
        $(".highlight_box").addClass("highlight_box_white");
    }
});  

$(document).ready(function() {
        $(".btn").click(function() {
            var searchQ = "";
            var flag;
            var sProgram = '';
            
            $(".program_search").find(".even").find(".dll").each(function() {
                var current = $(this);
                $(current)[0].selectedIndex;
                
                if ((current)[0].selectedIndex > 0)
                    searchQ += "#" + $(current).val();
            });
            if (searchQ != "")
            {
                var args = searchQ.split('#');
                for (var i=0; i < prog_title.length; i++)
                {
                    for (var j=0;j<args.length;j++)
                    {
                        if (prog_title[i].split(',')[2].toUpperCase().search(args[j].toUpperCase()) != -1)
                            flag = true;
                        else {
                            flag = false;
                            break;
                        }
                    }
                    if (flag == true)
                    {
                        sProgram +=  "<a href='"+ prog_title[i].split(',')[1] +"' >"+ prog_title[i].split(',')[0] +"</a><br />";
                    }
                }
                
                
                $(".program_search").find(".odd").find(".hs_temp").each(function() {
                    var current = $(this);
                    var hfHidden = document.getElementById(current.attr('id'));
                    hfHidden.value = sProgram;
                });
            }
        });
    }); 

function searchRes()
    {
        // {BBDC30C7-3CB2-4CBD-A97D-A487A036E00A} - AI
        // {F5F621CE-6A2C-452F-8932-85D8206E9C11} - DD
        // {8D5D5D7B-2B0B-490C-8576-907AAFA370AC} - FC
        // {69ED0D58-82DB-4E03-A42A-E8681D1AF904} - CM
        // {4289255A-A44C-43AD-B9F2-97AD75AE60DF} - liberal arts and studies
        // {D5D8770C-F1A4-4E84-91D5-4592C3DE684F} - HAZEL McCALLION CAMPUS
        var searchQ;var flag;var sProgram = '';
        
        if (searchQ != "")
            searchQ = "";
            
            
        var ddlAI = document.getElementById('<%= ddlAI.ClientID %>');// document.get .getElementById("ctl14_ctl05_ddlAI");
        if (ddlAI.selectedIndex > 0)
            searchQ += "#" + ddlAI.options[ddlAI.selectedIndex].value;

        var ddlCampus = document.getElementById('<%= ddlCampus.ClientID %>');// document.getElementById("ctl14_ctl05_ddlCampus");
        if (ddlCampus.selectedIndex > 0)
            searchQ += "#" + ddlCampus.options[ddlCampus.selectedIndex].value;
        
        var ddlFaculty = document.getElementById('<%= ddlFaculty.ClientID %>');// document.getElementById("ctl14_ctl05_ddlFaculty");
        if (ddlFaculty.selectedIndex > 0)
            searchQ += "#" + ddlFaculty.options[ddlFaculty.selectedIndex].value;
        
        var ddl_Dip_Degree = document.getElementById('<%= ddl_Dip_Degree.ClientID %>');// document.getElementById("ctl14_ctl05_ddl_Dip_Degree");
        if (ddl_Dip_Degree.selectedIndex > 0)
            searchQ += "#" + ddl_Dip_Degree.options[ddl_Dip_Degree.selectedIndex].value;
        
        var args = searchQ.split('#');
        for (var i=0; i < prog_title.length; i++)
        {
            for (var j=0;j<args.length;j++)
            {
                if (prog_title[i].split(',')[2].toUpperCase().search(args[j].toUpperCase()) != -1)
                {
                    flag = true;
                }
                else
                {
                    flag = false;
                    break;
                }
            }
            if (flag == true)
            {
                sProgram +=  "<a href='"+ prog_title[i].split(',')[1] +"' >"+ prog_title[i].split(',')[0] +"</a><br />";
//              sProgram +=  prog_title[i].split(',')[0].toUpperCase() + "\n";
            }
//            if (prog_title[i].split(',')[0].toLowerCase().search(sVal.toLowerCase()) != -1)
//            {
//                l.innerHTML += "<a href='"+ prog_title[i].split(',')[1] +"' >"+ prog_title[i].split(',')[0] +"</a><br />";
//                l.style.display = 'block';
//                l.setAttribute("class", "divShow");
//                l.setAttribute("className", "divShow"); 
//            }
        }
        
        if (sProgram != "")
        {
            var hfHidden = document.getElementById('<%= hfHidden.ClientID %>');//document.getElementById('ctl14_ctl05_hfHidden');
            hfHidden.value = sProgram;
        }
    }
    
    
////////// GENERATE TABLE OF CONTENTS /////////////
$(document).ready(function() {
    
    

    var strToc = "";
    var strToc2 = "";
    var totalItem = $(".hs_temp").length / 2;
    $(".hs_temp").each(function(i) {
        var current = $(this);

        if (i < totalItem)
            strToc += "<li><a href='#" + current.attr('id') + "'>" + current.next().html() + "</a></li>";
        else
            strToc2 += "<li><a href='#" + current.attr('id') + "'>" + current.next().html() + "</a></li>";
    });
    $("#toc").append("<ul>" + strToc + "</ul>");
    $("#tocBottom").append("<ul>" + strToc + "</ul>");
    $("#toc2").append("<ul>" + strToc2 + "</ul>");
    $("#tocBottom2").append("<ul>" + strToc2 + "</ul>");
}); 


$(document).ready(function()
{
        $("#viewNews").click(function () 
        {
            if ( $('#news_event').is(':visible')){
                $("#news_event").hide("slow");
             } 
             else
             {
                $("#news_event").show("slow");
             }
             return false;
        });
        
        $("#img_viewNews").click(function () 
        {
            if ( $('#news_event').is(':visible')){
                $("#news_event").hide("slow");
             } 
             else
             {
                $("#news_event").show("slow");
             }
             return false;
        });
        
        $("#tbTitle").keypress(function(e){
                c = e.which ? e.which : e.keyCode;            
                if(c == 13) 
                {
                    var code = $("#tbTitle").val();
                    code = jQuery.trim(code);
                    var str = "http://sculptor.sheridanc.on.ca/webapp/wcs/stores/servlet/CatalogSearchResultView?storeId=10051&catalogId=10051&langId=-1&pageSize=12&beginIndex=0&sType=SimpleSearch&resultType=2&searchTerm="+code;
                    str = jQuery.trim(str);
                    window.open(str);
                    $("#tbTitle").val('');
                    return false;
                }

            });  
            
            
            
        });
        
        
function sAlert()
{
   titleheight=25 //title Height
   titlecolor="#99CCFF";//title color
   var sWidth,sHeight; 
   sWidth= document.body.offsetWidth; 
   sHeight=document.body.offsetHeight; //screen.height; 
   
   var bgObj=document.createElement("div"); 
   bgObj.setAttribute('id','bgDiv'); 
   bgObj.style.position="absolute"; 
   bgObj.style.top="0"; 
   bgObj.style.background="#000000"; 
   bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75"; 
   bgObj.style.opacity="0.6"; 
   bgObj.style.left="0";
   bgObj.style.width = sWidth + "px";
   bgObj.style.height = sHeight + "px"; 
   bgObj.style.zIndex = "10000"; 
   document.body.appendChild(bgObj); 
   
   
   
   var msgObj=document.createElement("div") 
   msgObj.setAttribute("id","msgDiv"); 
   msgObj.setAttribute("align","center");
   msgObj.style.position = "absolute"; 
   msgObj.style.top = (sHeight/2)+"px"; 
   msgObj.style.left = (sWidth/2)+"px"; 
   msgObj.style.right = "350px"; 
   msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif"; 
   msgObj.style.width =  "350px"; 
   msgObj.style.height = "auto"; 
   msgObj.style.textAlign = "center";
   msgObj.style.vAlign = "center"; 
   msgObj.style.zIndex = "10001"; 
   document.body.appendChild(msgObj);      
   
   var imgdel = document.createElement("img");    
   imgdel.src="/common/images/wait.gif";
   imgdel.style.width =  "70px"; 
   imgdel.style.height = "70px";
   document.getElementById("msgDiv").appendChild(imgdel); 
   
   return true;
}
   

