$j = jQuery.noConflict();     

var agent=navigator.userAgent.toLowerCase();
var is_iphone = (agent.indexOf('iphone')!=-1);
if (!is_iphone) {

    $j(document).ready(function() {
        $j("#navigation > li[class!='selected'] > a").stop()
        .animate({ width: "100%" }, { queue: true, duration: 2000 })
        .animate({ backgroundPosition: "(0 -32px)" }, { duration: 300 });
        $j("#tabs > li[class!='selected'] > a").stop()
        .animate({ height: "148px" }, { duration: 2000 })
        .animate({ backgroundPosition: "(-21px 0)" }, { duration: 300 });
        $j("#homeTabs > li[class!='selected'] > a").stop()
        .animate({ height: "23px" }, { duration: 2000 })
        .animate({ backgroundPosition: "(0 20px)" }, { duration: 300 });

        $j("#navigation > li[class!='selected'] > a").mouseover(function() {
            $j(this).stop().animate({ backgroundPosition: "(0 20px)" }, { duration: 150 }).animate({ backgroundPosition: "(0 6px)" }, { duration: 100 });
        });
        $j("#navigation > li[class!='selected'] > a").mouseout(function() {
            $j(this).stop().animate({ backgroundPosition: "(0 -32px)" }, { duration: 150 });
        });
        $j("#tabs > li > a").mouseover(function() {
            if (!$j(this).parent().hasClass("selected")) {
                $j(this).stop().animate({ backgroundPosition: "(0 0)" }, { duration: 150 });
            }
        });
        $j("#tabs > li > a").mouseout(function() {
            if (!$j(this).parent().hasClass("selected")) {
                $j(this).stop().animate({ backgroundPosition: "(-21px 0)" }, { duration: 150 });
            }
        });
        $j("#tabs > li > a").click(function() {
            $j(".text > div").addClass("jshide");
            $j("#tabs > li").removeClass("selected");
            $j("#" + $j(this).parent().attr("id").replace("tab", "")).removeClass("jshide");
            $j(this).parent().addClass("selected");
            $j("#tabs > li[class!='selected'] > a").stop().animate({ backgroundPosition: "(-21px 0)" }, { duration: 150 });
        });
        $j("#homeTabs > li > a").mouseover(function() {
            if (!$j(this).parent().hasClass("selected")) {
                $j(this).stop().animate({ backgroundPosition: "(0 0)" }, { duration: 150 });
            }
        });
        $j("#homeTabs > li > a").mouseout(function() {
            if (!$j(this).parent().hasClass("selected")) {
                $j(this).stop().animate({ backgroundPosition: "(0 20px)" }, { duration: 150 });
            }
        });
        $j("#homeTabs > li > a").click(function() {
            $j("#twitter > .text > div").addClass("jshide");
            $j("#homeTabs > li").removeClass("selected");
            $j("#" + $j(this).parent().attr("id").replace("tab", "")).removeClass("jshide");
            $j(this).parent().addClass("selected");
            $j("#homeTabs > li[class!='selected'] > a").stop().animate({ backgroundPosition: "(0 20px)" }, { duration: 150 });
        });
        $j(".screenshots > .thumbs > a").click(function() {
            $j(this).parent().parent().children("img").attr("src", $j(this).attr("href"));
            return false;
        });

        var arVersion = navigator.appVersion.split("MSIE")
        var version = parseFloat(arVersion[1])

        if ((version >= 5.5 && version < 7) && (document.body.filters)) {
            for (var i = 0; i < document.images.length; i++) {
                var img = document.images[i]
                var imgName = img.src.toUpperCase()
                if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") {
                    var imgID = (img.id) ? "id='" + img.id + "' " : ""
                    var imgClass = (img.className) ? "class='" + img.className + "' " : ""
                    var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
                    var imgStyle = "display:inline-block;" + img.style.cssText
                    if (img.align == "left") imgStyle = "float:left;" + imgStyle
                    if (img.align == "right") imgStyle = "float:right;" + imgStyle
                    if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
                    var strNewHTML = "<span " + imgID + imgClass + imgTitle
                 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
                 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
                    img.outerHTML = strNewHTML
                    i = i - 1
                }
            }
        }

    });
} else {
    $j(document).ready(function() {
        $j("#tabs > li > a").click(function() {
            $j(".text > div").addClass("jshide");
            $j("#" + $(this).parent().attr("id").replace("tab", "")).removeClass("jshide");
        });
    });
}

function showProject(projectName) {
    $j(".ourWorkSubContent").addClass("jshide");
    $j("#" + projectName).removeClass("jshide");
    $j("#testimonialHolder").html($j("#" + projectName + " .testimonial").html());
    $j("#" + projectName + " .testimonial").addClass("jshide");
    return false;
}

/**
* @author Alexander Farkas
* v. 1.03
*/
(function($) {

    function toArray(strg) {
        strg = strg.replace(/left|top/g, '0px');
        strg = strg.replace(/right|bottom/g, '100%');
        strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g, "$1px$2");
        var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
        return [parseFloat(res[1], 10), res[2], parseFloat(res[3], 10), res[4]];
    }
    $.extend($.fx.step, {
        backgroundPosition: function(fx) {
            if (!fx.bgPosReady) {
                var start = $.curCSS(fx.elem, 'backgroundPosition');
                if (!start) {
                    return false;
                }
                start = toArray(start);
                fx.start = [start[0], start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0], end[2]];
                fx.unit = [end[1], end[3]];
                fx.bgPosReady = true;
            }
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
            fx.elem.style.backgroundPosition = nowPosX[0] + ' ' + nowPosX[1];
        }
    });
})(jQuery);

