﻿      var selectedTab = null;
      var panels = new Array('divColleges', 'divReviews', 'divVideos', 'divArticles');
      
      function changeClass(cObject, className)
      {
          if (navigator.appName == "Microsoft Internet Explorer") {
                cObject.className = className;
            }
            else{
                cObject.setAttribute("class",className);
            }
      }
      
      function showPanel(tab, name) {  
        if (selectedTab) {   
          changeClass(selectedTab,"taboff");
        }
        else { 
            selectedTab = document.getElementById('tabColleges');
            changeClass(selectedTab,"taboff");
        }
        selectedTab = tab;
        changeClass(selectedTab,"tabon");

        for(i = 0; i < panels.length; i++)
        {
          document.getElementById(panels[i]).style.display = (name == panels[i]) ? 'block':'none';          
        }
        return false;
      }
      
window.eventBag = {

    addEventHandler: function(eventName, handler) {
        if (!(typeof (eventName) === "string")) {
            throw "Argument 'eventName' must be a string.";
        }

        if (!(handler instanceof Function)) {
            throw "Argument 'handler' must be a function.";
        }

        if (!this.hasOwnProperty(eventName)) {
            this[eventName] = new Array();
        }
        this[eventName].push(handler);
    },

    removeEventHandler: function(eventName, handler) {
        if (!(typeof (eventName) === "string")) {
            throw "Argument 'eventName' must be a string.";
        }

        if (!(handler instanceof Function)) {
            throw "Argument 'handler' must be a function.";
        }

        if (this.hasOwnProperty(eventName)) {
            var list = this[eventName];
            for (var i = 0; i < list.length; i++) {
                if (list[i] === handler) {
                    list.splice(i, 1);
                }
            }
        }
    }
};

Function.prototype.notifyImCalled = function() {
    if (this.hasOwnProperty("eventName")) {
        if (window.eventBag[this.eventName] instanceof Array) {
            var list = window.eventBag[this.eventName];
            for (var i = 0; i < list.length; i++) {
                list[i]();
            }
        }
    }
}

function attach(o, e, f) {
    if (document.attachEvent)
        o.attachEvent("on" + e, f);
    else if (document.addEventListener)
        o.addEventListener(e, f, false);
}



function ImproveEmptyAppearance(objid, emptymsg) {
    var obj = document.getElementById(objid);
    try {
        if (obj == null) {
            return;
        }
        if (obj.tagName.toLowerCase() != "input") {
            return;
        }
        if (obj.type.toLowerCase() != "text") {
            return;
        }
    }
    catch (e) {
        return;
    }

    jQuery(obj).bind("blur", function() {
        if (this.value == "" || this.isEmpty) {
            this.value = emptymsg;
            try {
                this.formalColor = this.currentStyle.color;
            }
            catch (e) {
                this.formalColor = document.defaultView.getComputedStyle(this, null).getPropertyValue("color");
            }
            try {
                this.runtimeStyle.color = "gray";
            }
            catch (e) {
                this.style.color = "gray";
            }
            this.isEmpty = true;
        }
    });

    jQuery(obj).bind("focus", function() {
        if (this.isEmpty) {
            this.value = "";
            if (this.formalColor != null) {
                try {
                    this.runtimeStyle.color = this.formalColor;
                }
                catch (e) {
                    this.style.color = this.formalColor;
                }
            }
            this.isEmpty = false;
        }
        else {
            try {
                this.select();
            } catch (e) { }
        }
    });

    var theForm = obj.parentElement;
    while (theForm) {
        if (theForm.tagName.toLowerCase() == "form") {
            break;
        }
        theForm = theForm.parentElement;
    }
    if (theForm) {
        attach(theForm, "submit", function() {
            if (obj.isEmpty) {
                obj.value = "";
            }
        });
    }

    jQuery(obj).blur();
}





var answerFunction;


function GetRadWindow() {
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow;
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    return oWindow;
}

function Close() {
    var window = GetRadWindow();
    window.Close();
}

function answer(response) {
    answerFunction(response);

}



var w3c = (document.getElementById) ? true : false;
var agt = navigator.userAgent.toLowerCase();
var ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1) && (agt.indexOf("omniweb") == -1));
var ie5 = (w3c && ie) ? true : false;
var ns6 = (w3c && (navigator.appName == "Netscape")) ? true : false;
var op8 = (navigator.userAgent.toLowerCase().indexOf("opera") == -1) ? false : true;



function getEvent() {
    if (document.all) return window.event;
    func = getEvent.caller;
    while (func != null) {
        var arg0 = func.arguments[0];
        if (arg0) {
            if ((arg0.constructor == Event && arg0.constructor == MouseEvent) || (typeof (arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)) {
                return arg0;
            }
        }
        func = func.caller;
    }
    return null;
}

function GetCenterPosition() {
    var top = 0, left = 0;
    if (typeof (window.pageYOffset) == 'number') {
        //Netscape compliant
        top = window.pageYOffset;
        left = window.pageXOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        //DOM compliant
        top = document.body.scrollTop;
        left = document.body.scrollLeft;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        //IE6 standards compliant mode
        top = document.documentElement.scrollTop;
        left = document.documentElement.scrollLeft;
    }

    return [top, left];
}

var currentUrl;

function closeopenwindow() {
    var url = currentUrl;
    if (currentUrl == undefined && window.parent) {
        url = window.parent.currentUrl;
    }
    var divplaceholderid = "divplaceholder-" + url;
    var p1windowid = "p1window-" + url;

    var element = document.getElementById(divplaceholderid);
    var execCount = 0;
    while (!element) {
        element = window.parent.document.getElementById(divplaceholderid);
        execCount += 1;
        if (execCount > 100) break;
    }
    if (element) {
        element.style.display = "none";
    }

    var element1 = document.getElementById(p1windowid);
    execCount = 0;
    while (!element1) {
        element1 = window.parent.document.getElementById(p1windowid);
        execCount += 1;
        if (execCount > 100) break;
    }
    if (element1) {
        element1.style.display = "none";
    }
}
function openwindow(url, width, height, showModel) {
    openwindowByVisible(url, width, height, showModel, "");
}
function openwindowByVisible(url, width, height, showModel, visible) {
 
    var findout = false;

    var rooturl = url.split("?")[0];

    var divplaceholderid = "divplaceholder-" + rooturl;
    var p1windowid = "p1window-" + rooturl;
    var innerframeid = "innerframe-" + rooturl;

    var p = document.getElementById(divplaceholderid);
    if (!p) {
        p = document.createElement("DIV");
        p.id = divplaceholderid;

        p.style.position = "absolute";
        p.style.top = '0px';
        p.style.left = '0%';

        document.body.appendChild(p);
    }
    else {
        findout = true;
    }


    p.style.width = document.body.scrollWidth + 20 + "px";
    //p.style.height = (document.body.offsetHeight > document.body.scrollHeight) ? '100%' : document.body.scrollHeight + 20 + "px";
    p.style.height =(document.getElementsByTagName('html')[0].scrollHeight > document.body.scrollHeight)?document.getElementsByTagName('html')[0].scrollHeight+"px" :document.body.scrollHeight+"px";

    if (showModel == true) {
        p.style.zIndex = '999';
        p.style.backgroundColor = "#ccc";
        p.style.opacity = '0.5';
        p.style.filter = "alpha(opacity=80)";
        p.style.display = "none";
    }
    else {
        p.style.zIndex = '-1';
        p.style.backgroundColor = "transparent";
    }


    var p1 = document.getElementById(p1windowid);
    if (!p1) {
        findout = false;
        p1 = document.createElement("DIV");
        p1.id = p1windowid;

        p1.style.position = "absolute";
        p1.style.border = "0px solid red";
        p1.style.display = "none";
    }
    else {
        findout = true;
    }

    var position = GetCenterPosition();
    var top = position[0];
    var left = position[1];
    top = parseInt(top + (document.documentElement.clientHeight - height) / 2);
    left = parseInt(left + (document.documentElement.clientWidth - width) / 2);
    scrollEvent = function() {
        var _p = document.getElementById(divplaceholderid);
        if (p) {
            var _p1 = document.getElementById(p1windowid);
            if (_p1) {
                var _position = GetCenterPosition();
                top = _position[0];
                left = _position[1];
                top = parseInt(top + (document.documentElement.clientHeight - height) / 2);
                left = parseInt(left + (document.documentElement.clientWidth - width) / 2);
                _p1.style.top = top - 40 + 'px';
                _p1.style.left = left + 'px';
            }
        }
    }

    if (document.all) {
        window.attachEvent("onscroll", scrollEvent);
    }
    else {
        document.addEventListener("scroll", scrollEvent, false);
    }
    p1.style.width = width + "px";
    p1.style.height = height + "px";
    p1.style.zIndex = '1000';
    p1.style.top = top - 40 + 'px';
    p1.style.left = left + 'px';
    //Code commented by : Ideavate (Shailendra)
    //Purpose : ticket #586
    //Date : 10 june 2009
//    if (!findout) {
        var html = "";
        html += "<center>"
        html += '<table cellspacing="0" cellpadding="0" border="0" style="z-index: 3006; width: ' + width + 'px;height: ' + height + 'px; position: absolute; left: 50%; top: 50%; margin-left: -' + width / 2 + 'px;margin-top:-' + height / 2 + 'px; text-align: center;"><tbody style="height: 100%;"><tr height="100%" style="height: 100%;"><td id="" align="left" style="width: 100%; height: 100%;" colspan="8"><iframe id="' + innerframeid + '" frameborder="0" border="no" src="' + url + '" style="border: 0px solid green;width: 100%; height: 100%;"  allowtransparency="true"></iframe></td></tr></tbody></table>'
        html += "</center>"
        document.body.appendChild(p1);
        p1.innerHTML = html;
//    }
//    else {
//        var innerframe = document.getElementById(innerframeid);
//        if (innerframe.contentWindow.setActionValue) {
//            var action = "forward";
//            var value = url.getQuery(action);
//            if (value == null) {
//                action = "Jsript";
//                value = url.getQuery(action);
//            }
//            if (value == null) {
//                action = "GoMyUnigo";
//                value = url.getQuery(action);
//            }
//            if (value == null || value == "") {
//                action = "";
//                value = "";
//            }
//            var message = url.getQuery("message");
//            innerframe.contentWindow.setActionValue(action, value, message);
//        }
//        if (innerframe.contentWindow.clearPassword) {
//            innerframe.contentWindow.clearPassword();
//        }
//    }
    p.style.display = visible;
    p1.style.display = visible;
    currentUrl = rooturl;
}

String.prototype.getQuery = function(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = this.substr(this.indexOf("\?") + 1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}

function NoReviewAlert() {
    openwindow('/html/noreview.aspx', 440, 250);
    var ev = getEvent();
    if (!document.all) { ev.preventDefault(); }
    return false;
}

function RequestStart() {
    document.body.style.cursor = 'wait';
}
function ResponseEnd() {
    document.body.style.cursor = '';
}

/**
 * Added By: Ideavate [Manoj1]
 * Date: April 22, 2009
 * Ticket# 493
 * Reason: function confilt in man,js and main_homepage.js
 **/

function changeSafeURL() {
    var links = document.getElementsByTagName('a');
    var safelinks = [];
    
  
    var tmpAlert;
    for (i = 0; i < links.length; i++) {
          var link = links[i];
       
        if (link.href.toLowerCase().indexOf('/explorer/profiles/profile.aspx') > 0) {
           
            var redirect= new String();
            redirect=link.href.toString();
           
           
            link.href='javascript:void(0)';

            link.onclick = function() { return AlertUnregisteredWithRedirectToProfile(redirect); }
            
        }
    }
}


/**
* end
*/

function tellAFriend() {
    if (sendEmail) sendEmail();
}

function uploadVideos() {
    if (uploadVideo) uploadVideo();
}

function uploadPhotos() {
    if (uploadPhoto) uploadPhoto();
}

function uploadDocuments() {
    if (uploadDocument) uploadDocument();
}

var Cookies = {};
Cookies.set = function(name, value) {
    var argv = arguments;
    var argc = arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : '/';
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + "=" + escape(value) +
       ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
       ((path == null) ? "" : ("; path=" + path)) +
       ((domain == null) ? "" : ("; domain=" + domain)) +
       ((secure == true) ? "; secure" : "");
};
Cookies.get = function(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    var j = 0;
    while (i < clen) {
        j = i + alen;
        if (document.cookie.substring(i, j) == arg)
            return Cookies.getCookieVal(j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0)
            break;
    }
    return null;
};
Cookies.clear = function(name) {
    if (Cookies.get(name)) {
        var expdate = new Date();
        expdate.setTime(expdate.getTime() - (86400 * 1000 * 1));
        Cookies.set(name, "", expdate);
    }
};
Cookies.getCookieVal = function(offset) {
    var endstr = document.cookie.indexOf(";", offset);
    if (endstr == -1) {
        endstr = document.cookie.length;
    }
    return unescape(document.cookie.substring(offset, endstr));
};

function searchKeydown(typeName, valueName) {
    var ev = getEvent(); //e||window.event;
    if (ev.keyCode == 13) {
        fireSearch(typeName, valueName);
        if (!document.all) {
            ev.preventDefault();
        }
        else {
            event.returnValue = false;
        }
        return false;
    }
}

function fireSearch(typeName, valueName) {
    var _type = jQuery("#" + typeName).val();
    var _keyWord = jQuery("#" + valueName).val();
    if (_keyWord == "Search Unigo" || jQuery.trim(_keyWord).length < 1) {
        alertFnMsg("Please enter a word or phrase so we can help you find what you're looking for!", "jQuery(\"#" + valueName + "\").val(\"\").focus()");
        return;
    }
    var _url;
    switch (_type) {
        case "video":
            _url = "/explorer/videos/videodirectory.aspx?keywords=" + _keyWord + "&usertype=0";
            break;
        case "photo":
            _url = "/explorer/photos/photodirectory.aspx?keywords=" + _keyWord + "&usertype=0";
            break;
        case "document":
            _url = "/explorer/documents/documentdirectory.aspx?keywords=" + _keyWord + "&usertype=0";
            break;
        case "collegereview":
            _url = "/explorer/reviews/reviewdirectory.aspx?keywords=" + _keyWord + "&usertype=0";
            break;
        case "college":
            _url = "/colleges/?keywords=" + _keyWord + "&from=adv";
            break;
        case "article":
            _url = "/search/featuredsearch.aspx?keywords=" + _keyWord + "";
            break;
      
        case "keyword":
        case "profile":
        default:
            _url = "/explorer/profiles/profiledirectory.aspx?keywords=" + _keyWord + "&usertype=0";
            break;
    }
    
    location.href = _url + "&newsearch=true" + "&searchfrom=" + _type;
}

var isSelect = true;




