﻿jQuery.fn.opacityToggle = function (speed, easing, callback) {
    return this.animate({ opacity: 'toggle' }, speed, easing, callback);
}

function hideUrlBar() {
    window.scrollTo(0, 1);
}

//  Blankwin function 
//  written by Alen Grakalic, provided by Css Globe (cssglobe.com)
//  please visit http://cssglobe.com/post/1281/open-external-links-in-new-window-automatically/ for more info
function openExtLinkInNewWin() {
    var hostname = window.location.hostname.toLowerCase();
    var domain = "questechsystems.com";
    hostname = hostname.replace("www." + domain, domain).replace("m." + domain, domain);
    //var hostname = "questechsystems.com";
    var a = document.getElementsByTagName("a");
    this.check = function (obj) {
        var href = obj.href.toLowerCase();
        return (href.indexOf("http://") != -1 && href.indexOf(hostname) == -1) ? true : false;
    };
    this.set = function(obj) {
        obj.target = "_blank";
        //obj.className = "external";
    };
    for (var i = 0; i < a.length; i++) {
        if (check(a[i])) set(a[i]);
    };
};

function toggleArticleDetails() {
    jQuery('a.toggleDetails').unbind('click').click(function () {
        jQuery(this).toggleClass('open');
        var parentPost = jQuery(this).parents("div.article");
        if (parentPost.length) {
            var firstParent = jQuery(parentPost.get(0));
            firstParent.find('div.details').opacityToggle(350);
        }
        return false;
    });
}

function doReady() {
    toggleArticleDetails();
}

addOnloadEvent(hideUrlBar);
addOnloadEvent(openExtLinkInNewWin);

jQuery(document).ready(function () { doReady(); });