$(document).ready(function () {
 $("#slideshow").tw_slideshow();

    // switch(Math.floor(Math.random()*6))
    // {
    //  case 0:
    //      $("#wrapper").show('explode', {}, 1000);
    //  break;
    //  case 1:
    //      $("#wrapper").show('fold', {}, 1000);
    //  break;
    //  case 2:
    //      $("#wrapper").show('blind', {'direction': 'horizontal'}, 1000);
    //  break;
    //  case 3:
    //      $("#wrapper").show('drop', {'direction': 'down'}, 1000);
    //  break;
    //  case 4:
    //      $("#wrapper").show('fade', {}, 1000);
    //  break;
    //  case 5:
    //      $("#wrapper").show('puff', {}, 1000);
    //  break;
    // }
	
	
	
	
  /***********************************************
	 * CONTENT ACCORDIAN
	 ***********************************************/
	$("body #copy div.accordian p, body #copy div.lightcontent p, body #copy div.accordian form").hide();
	
	$("body #copy div.accordian strong").not('div.accordian p strong').click(function () {
		var current = $(this).closest('.accordian').find('p, form');
		$("body #copy div.accordian p:visible, body #copy div.accordian form:visible").slideUp();
		current.toggle();
	}).css({'cursor': 'pointer'});
	
	
	
	
	
	
	
	/***********************************************
	 * CONTENT LIGHTBOX
	 ***********************************************/
	$("body #copy div.lightcontent strong").not('div.lightcontent p strong').click(function () {
	  $("#lightbox, #popup").remove();
	  $("body").append('<div id="lightbox"></div><div id="closepopup">[x] close</div><div id="popup"><div id="logo"><a href="/"><h1>Accell Property Management</h1></a></div></div>');
	  
	  $("#popup").css({
	    'top': ($(window).height() / 2) - (600 / 2) + $(window).scrollTop(),
      'left': ($(window).width() / 2) - (690 / 2)
	  });
	  
	  $("#closepopup").css({
	    'width': '50px',
	    'height': '20px',
	    'text-align': 'center',
	    'line-height': '20px',
	    'vertical-align': 'center',
	    'background': '#ccc',
	    'color': '#000',
	    'top': $("#popup").offset().top - 20 + 'px',
	    'left': $("#popup").offset().left + 684 + 'px',
	    'position': 'absolute',
	    'cursor': 'pointer',
	    'font-size': '12px'
	  });
	  
	  // show paragrahps
	  $("#popup").append($(this).closest('.lightcontent').html()).find('p').show();
	  
	  $("#lightbox").css({
	    'position': 'absolute',
	    'top': '0px',
	    'left': '0px',
	    'width': '100%',
	    'height': $(document).height(),
	    'background': '#fff',
	    'opacity': 0.7
	  });
	  
	  // disable heading click
	  $("#popup strong").css({'cursor': 'auto'}).click(function () { return false; });
	  
	  // back to top button
    // $("#popup").find('a[href=#top]').click(function () {
    //   $("#popup").scrollTop(0);
    //   return false;
    // });
	}).css({'cursor': 'pointer'});
	
	$("#lightbox, #closepopup").live('click', function () {
	  $("#lightbox, #popup, #closepopup").fadeOut('fast', function () {
	    $("#lightbox, #popup, #closepopup").remove();
	  });
	});
	
	// page transitions
	// $("#nav a").click(function () {
	// 	var href = $(this).attr('href');
	// 	var effect = Math.floor(Math.random()*6);
	// 	switch(effect) {
	// 		case 0:
	// 			$("#wrapper").effect('blind', {'direction': 'horizontal'}, 400, function () { window.location = href; });
	// 			break;
	// 		case 1:
	// 			$("#wrapper").effect('fold', {}, 400, function () { window.location = href; });
	// 			break;
	// 		case 2:
	// 			$("#wrapper").effect('explode', {}, 400, function () { window.location = href; });
	// 			break;
	// 		case 3:
	// 			$("#wrapper").effect('drop', {'direction': 'down'}, 400, function () { window.location = href; });
	// 			break;
	// 		case 4:
	// 			$("#wrapper").effect('fade', {}, 400, function () { window.location = href; });
	// 			break;
	// 		case 5:
	// 			$("#wrapper").effect('puff', {}, 400, function () { window.location = href; });
	// 			break;
	// 	}
	// 	
	// 	return false;
	// });
	
	$(".change_address form").validate();
	$(".request_escrow form").validate();
	
	// fake banner ads
	swapAd($("#banner1"));
	swapAd($("#banner2"));
	setInterval(function () {
	    swapAd($("#banner1"));
    	swapAd($("#banner2"));
	}, 5000)
});

function swapAd(object) {
    var bgcolorlist=new Array("#33CCFF", "#99CC00", "#FF66CC", "#996633", "#FFFF00", "#333399", "#FF00FF", "#777777")
    var text = new Array("Another Banner Ad", "Great Banner", "Test Banner Ad", "Sample Banner", "Amazing Banner")
    object.css({'background': bgcolorlist[Math.floor(Math.random()*bgcolorlist.length)]})
    object.find('p strong').html(text[Math.floor(Math.random()*text.length)] + '<br />&nbsp;');
}
