/* personalize? */
// var user = new Array();
// user['username'] = "<USERNAME>";
// user['thumbnail'] = "";
// user['following'] = "413";
// user['followers'] = "791";
// user['tweets'] = "1,116";
// not sure if we're going to use this yet

/* custom theme obj */
// function theme(bg_img, bg_color){
//     this.bg_img = bg_img
//     this.bg_color = bg_color
// }

/* theme details */
// var themes = new Array();
// themes[1] = new theme("images/theme1.jpg",'red');
// themes[2] = new theme("images/theme2.jpg",'blue');
// themes[3] = new theme("images/theme3.jpg",'green');
// themes[4] = new theme("images/theme4.jpg",'pink');
// themes[5] = new theme("images/theme5.jpg",'red');
// themes are stored in a global "themes" variable populated on page load


function select_theme(theme_id) {
   selected_theme_id = theme_id;
   document.title = themes[selected_theme_id].title + " - Tweety Got Back - A Twitter Theme Shoppe | Free Twitter Backgrounds and Themes"
   $("#theme_name_link").text(themes[theme_id].title).attr("href", "/themes/" + theme_id);
   $("#apply_theme_link").attr("href", "/themes/apply/" + theme_id);
   $("body.preview").css({
      'background': themes[theme_id].profile_background_color + 
      " url(" + themes[theme_id].profile_background_image_url + ") fixed " + 
      (themes[theme_id].profile_background_tile ? "repeat" : "no-repeat") + " 0 60px"
   });
   $(".profile_text_color").css("color", themes[theme_id].profile_text_color);
   $(".profile_link_color").css("color", themes[theme_id].profile_link_color);
   $(".profile_sidebar_color").css({
      "background-color": themes[theme_id].profile_sidebar_fill_color,
      "border-left": themes[theme_id].profile_sidebar_border_color
   });
   $(".profile_sidebar_border_color").css({
      "color": themes[theme_id].profile_sidebar_border_color,
      "background-color": themes[theme_id].profile_sidebar_border_color
   });
	if (themes[theme_id].layout_facebook_url != null) {
		$(".download_fb").removeClass("fb_cover_disabled");
	} else {
		$(".download_fb").addClass("fb_cover_disabled");
	}
}

function parse_id(el_id) {
   return parseInt(el_id.replace("layout_", "").replace("theme_", ""));
}

$('a.preview_thumb').live('click', function(e) {
   select_theme(parse_id(this.id));
   return false;
})
