﻿function roundedCorners() {
    var divs = document.getElementsByTagName('div');
    var rounded_divs = [];
    for (var i = 0; i < divs.length; i++) {
        if (/\brounded\b/.exec(divs[i].className)) {
            rounded_divs[rounded_divs.length] = divs[i];
        }
    }
    for (var i = 0; i < rounded_divs.length; i++) {
        var original = rounded_divs[i];
        /* Make it the inner div of the four */
        //original.className = original.className.replace('rounded', '');
        /* Now create the outer-most div */
        var tr = document.createElement('div');
        tr.className = 'r';
        /* Swap out the original (we'll put it back later) */
        original.parentNode.replaceChild(tr, original);
        /* Create the two other inner nodes */
        var tl = document.createElement('div');
        tl.className = 'r';
        var br = document.createElement('div');
        br.className = 'r';
        /* Now glue the nodes back in to the document */
        tr.appendChild(tl);
        tl.appendChild(br);
        br.appendChild(original);
    }
}


doSearch = function() {
    document.location.href='/' + $('#searchBox').val();
}


showDialog = function(title, msg, url) {
    Boxy.load('/Popups/TweetThis.aspx?TITLE=' + title + '&MSG=' + msg + '&URL=' + url, { modal: true });
}




loginTwitter = function(ref) {
    Boxy.load('/Popups/RequireLogin.aspx?REF=' + ref, { modal: true });
}


showFollow = function() {
    Boxy.load('/Popups/FollowUs.aspx', { modal: true });
}


followUs = function(t) {
    $.get('genericAuth.asmx?T=FOLLOW', function(data) { Boxy.get(t).hide(); });
}

cancelFollow = function(t) {
$.get('genericAuth.asmx?T=NOFOLLOW', function(data) { Boxy.get(t).hide(); });
}

var newReviews = '';

createSimilarReviews = function(userRelationship) {
    var people = new Array();
    for (x = 0; x < $('.selected').length; x++) {
        people.push($('.selected')[x].id);
    }

    $('#createReviews').attr('disabled', 'disabled');
    $.get('genericAuth.asmx?T=SIMILAR&R=' + userRelationship + '&PEOPLE=' + people.join(','), function(data) {
        $('#createReviews').customFadeOut('fast');
        $('#saveTimeBlurb').customFadeOut('fast');
        newReviews = data; $('#avatarContent').customFadeOut('fast', function() { $('#avatarComplete').customFadeIn('fast'); })
    });
}


sendDialogTweet = function(msg, url, t) {
$.get('genericAuth.asmx?T=TWEET&MSG=' + msg, function(data) { Boxy.get(t).hide(function() { if ( url != '' ) document.location.href = url; }); });
}



fader = function(id, _in) {    
    if (_in) $('#' + id).customFadeIn('fast');
    if (!_in) $('#' + id).customFadeOut('fast');
}

if (typeof(Cufon) != "undefined") {
    Cufon.replace('h1');
    Cufon.replace('h2');
    Cufon.replace('h3');
    Cufon.replace('h4');
    Cufon.replace('h5');
}


