/* Author:

*/
	var mqs, loadedMediaQuery, mediaQueries, mq = [];
 	function getMediaQueries()
    {
        var sheetList = document.styleSheets,
            ruleList, i, j, mediaQueries = [];
        for (i = sheetList.length - 1; i >= 0; i--)
        {
            ruleList = sheetList[i].cssRules;
            if (ruleList)
            {
                for (j = 0; j < ruleList.length; j++)
                {
                    if (ruleList[j].type == CSSRule.MEDIA_RULE)
                    {
                        var query = ruleList[j].cssText.match(/@media only screen and (.*) {/);
                        if (query && query[1])
                        {
                            mediaQueries.push(query[1]);
                        }
                    }
                }
            }
        }
        return mediaQueries;
    }

    function pageSize()
    {
        if (window.matchMedia)
        {
            mqs = getMediaQueries();
            for (i = mqs.length - 1; i >= 0; i--)
            {
                mq[i] = window.matchMedia(mqs[i]);
            }
        }
        $(window).bind('resize', function ()
        {
            var cssProps = window.getComputedStyle($('body').get(0), null), width = window.innerWidth || cssProps.getPropertyValue('width'), height = window.innerHeight || cssProps.getPropertyValue('height');
            for (var i in mq)
            {
                mqChange(mq[i]);
            }
        }).trigger('resize');
        function mqChange(mq)
        {
            if (mq.matches)
            {
               loadedMediaQuery = mq.media.replace('(min-width: ', '').replace('px)', '');
            }
        }
        return loadedMediaQuery;
    }
	
    
function autoFill(id, v)
{

    if ($(id).val() == "")
    {
        $(id).css(
        {
            color: "#ccc"
        }).attr(
        {
            value: v
        }).focus(function ()
        {
            if ($(this).val() == v)
            {
                $(this).css(
                {
                    color: "#333"
                }).val("");
            }
        }).blur(function ()
        {
            if ($(this).val() == "")
            {
                $(this).css(
                {
                    color: "#ccc"
                }).val(v);
            }
        });
    }
    else
    {
        if ($(id).val() == v)
        {
            $(this).css(
            {
                color: "#333"
            });
        }
        else
        {
            $(this).css(
            {
                color: "#333"
            });
        }
        $(id).focus(function ()
        {
            if ($(this).val() == v)
            {
                $(this).css(
                {
                    color: "#333"
                }).val("");
            }
        }).blur(function ()
        {
            if ($(this).val() == "")
            {
                $(this).css(
                {
                    color: "#ccc"
                }).val(v);
            }
        });

    }

}

$(document).ready(function ()
{
    autoFill($("input#name"), "your name");
    autoFill($("input#email"), "your email");
    autoFill($("textarea#message"), "your message…");

	var offsetTop;
	if(pageSize()>479) {
		offsetTop = -150;
		$('#about').equalHeights();
	}
    $.localScroll(
    {
        hash: true,
        offset: {
            top: offsetTop
        }
    });
    $.localScroll.hash({
    	offset: {
            top: offsetTop
        }
    });
    
    
    $("#tweets").tweet({
        count: 5,
        username: "1020concepts",
        list: "team",
        loading_text: "loading list...",
        template: '{text}'
    });
      
});

