// This contains all base javascript (e.g. siFR, swfobject calls, etc)

//  base.js
//  
//  Created by Matt Dills on 2011-02-24.
//  Copyright 2010 Scully Group. All rights reserved.
// 

$(document).ready(function() {
  
  // /////////////////////////////////////////////////////////////// cufon
  // 
  // Copperplate Gothic Bold Condensed Bold
  Cufon.replace('#header ul.header-nav li a', {hover:true, fontFamily: 'Copperplate Gothic Bold'});
  Cufon.replace('#search label', {hover:true, fontFamily: 'Copperplate Gothic Bold'});
  Cufon.replace('#shop p', {hover:true, fontFamily: 'Copperplate Gothic Bold'});
  Cufon.replace('#flash-bling h2', {hover:true, fontFamily: 'Copperplate Gothic Bold'});
  
  Cufon.replace('#footer-nav ul li', {hover:true, fontFamily: 'Copperplate Gothic Bold'});
  Cufon.replace('#footer-nav ul li a', {hover:true, fontFamily: 'Copperplate Gothic Bold'});
  Cufon.replace('#signup label', {hover:true, fontFamily: 'Copperplate Gothic Bold'});
  Cufon.replace('#product-name h1', {hover:true, fontFamily: 'Copperplate Gothic Bold'});
  Cufon.replace('#also-recommended h1', {hover:true, fontFamily: 'Copperplate Gothic Bold'});  
  

  // Chopin Script
  Cufon.replace('#flash-bling h1', {hover:true, textShadow: '#333 1px 1px', fontFamily: 'ChopinScript'});
  Cufon.replace('#overall-rating h1', {hover:true, textShadow: '#333 1px 1px', fontFamily: 'ChopinScript'});
  
  //////////////////////////////////////////////////////////////// TABS
  $(function() {
		$('#home-share-tabs ').tabs({
		ajaxOptions: {
				error: function( xhr, status, index, anchor ) {
					$( anchor.hash ).html(
						"Couldn't load this tab. We'll try to fix this as soon as possible. " +
						"If this wouldn't be a demo." );
				}
			}
		});
  });
  
/*var importURL;
var clicked = new Array();
$(function() {

  var $tabs = $("#home-share-tabs").tabs({

    select: function(e, ui) {

      var thistab = ui.index;

      $("#tab" + thistab).html(getLink(thistab));

    }

  });

});

 

function getLink(thistab) {
  for (var x in clicked) {
    if (clicked[x] == thistab)
      return;
  }
  switch (thistab) {

    case 0:

      importURL = "importRSS.aspx?importURL=http%3a%2f%2fwww.facebook.com%2ffeeds%2fpage.php%3fid%3d134887836576991%26format%3drss20&importKey=15B0F2677813E42AA06C72F655F8EE6BF724F48C";

      break;

    case 1:

      importURL = "importRSS.aspx?importURL=http%3a%2f%2ftwitter.com%2fstatuses%2fuser_timeline%2fCampusCouture.rss&importKey=550F3D16E2794399F277C5662B3A5FCD6F9B65A0";

      break;

    case 2:

      importURL = "importRSS.aspx?importURL=http%3a%2f%2fblog.campuscouture.com%2f%3ffeed%3drss&importKey=1C8B7606FA08D3AE7623E381D4549C0564425CC8";

      break;
  }

  $.ajax({

    type: "GET",

    url: "'" + importURL + "'",

    dataType: "xml",

    success: function(response) {

      var feed = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;

      for (var i = 0; i < feed.length; i++) {

        $('#tab' + thistab).append('<p><strong>' + feed[i].Item + ' ' +

                              feed[i].Title + '</strong><br /> Description: ' +

                              feed[i].Description + '<br />Link: ' +

                              feed[i].Link + '<br /></p>');

      }

       clicked.push(thistab);

    }

  });

}
*/
 
    
  
 /*$(function() {
		$('#home-share-tabs').tabs({
		
		ajaxOptions: {
				cache:'false',
				error: function( xhr, status, index, anchor ) {
					$( anchor.hash ).html(
						"Couldn't load this tab. We'll try to fix this as soon as possible. " +
						"" );
				},
				success: function( xml, anchor ) {
             		$( xml ).find('item').find('title').each(function(){
               			var item_text = $(this).text();
              			$('<li></li>')
               			.html(item_text)
               			.appendTo( anchor.hash );
             		});
				}
			}
		}).simplerss({display:3});
	});
*/
  $(function() {
		$('#product-details').tabs();
	});
/*	
		$('#home-share-tabs ').tabs({
		ajaxOptions: {
				error: function( xhr, status, index, anchor ) {
					$( anchor.hash ).html(
						"Couldn't load this tab. We'll try to fix this as soon as possible. " +
						"If this wouldn't be a demo." );
				}
			}
		});


$('#home-share-tabs').tabs({
	    select: function(event, ui) {
	        var url = $.data(ui.tab, 'load.tabs');
	        if( url ) {
	            location.href = url;
	            return false;
	        }
	        return true;
	    }
	});	
*/	
	//////////////////////////////////////////////////////////////// dropdown on college teams
	$('#header ul.navigation li.college').each(function() {
    $(this).hover(function() {
      $(this).addClass('nav-on');
    }, function() {
      $(this).removeClass('nav-on');
    });
  });

  	$('#facebook-tab').wrapInner('<p></p>');
}); //end document.ready
