if ($j.browser.msie && ($j.browser.version == "6.0")) {
}
else {
	
}
 
function removeFlash() {
	//$j('#flash2').remove();
	$j("#flash2").html("");
}

$j(document).ready(function() {

	
	var totalNum = $j('.sponsorsbox .thumbs a').length;
	var numRand = Math.floor(Math.random()*totalNum);

	//console.log(numRand);
	
	$j('#postcardSlide').cycle({
		cleartype: true,
		cleartypeNoBg: true
	});
	
	if($j('#slides').length > 0) {
		$j('#slides').cycle({
			cleartype: true,
			cleartypeNoBg: true
		});
	}
	
	//$j("ul.video_list").ytplaylist({addThumbs:true, autoPlay: false, holderId: 'youtube'});
	//$j("ul.video_list").prettyPhoto();
	$j("#p_home #main").append("<div id='videos'></div>");
	$j('#videos').load('_assets/ajax.php?a=youtube');
	$j("._list_home").prependTo("#p_home #main #home-map")
	
	
	//$j(".video_list li a[rel^='prettyPhoto']").prettyPhoto({theme: 'facebook'});

	//$j('#postcardSlide').css('width','230px');
	
	$j('.sponsorsbox .thumbs a').click(function(e){
		e.preventDefault();
		var href = $j(this).attr('href');
		var img = $j(this).children('img').attr('src');
		img = img.replace('&e=desaturate','');
		img = img+'&w=270&h=155&r=resize';
		$j('.mainimage a').attr('href',href);
		$j('.mainimage a').html('<img src="'+img+'">');
		//$j('.mainimage a img').attr('src',img);
		$j('.sponsorsbox .thumbs a').removeClass('fullopacity');
		$j(this).addClass('fullopacity');
	});
	
	$j('.sponsorsbox .thumbs a:nth('+numRand+')').click();
	
	$j(".accordion").accordion({
		autoHeight: false
	});
	
	$j('._datatable').dataTable( {
		"bProcessing": true,
		"sAjaxSource": '_assets/ajax.php?a=list-members'		
	});
	
	$j("thead input").keyup( function () {
			/* Filter on the column (the index) of this element */
			$j('._datatable').dataTable().fnFilter( this.value, $j("thead input").index(this) );
	});
	
	$j("select[name=find_state]").change(function(e){
		var v = $j(this).val();
		v = $j.URLEncode(v);
		$j("input[name=find_zipcode]").val('');
		$j('span.find-county').load('_assets/ajax.php?a=list-counties&state='+v);
		
	});
	
	$j("select[name=find_state]").change();
	
	$j("ul.form select[name$=location_state]").change(function(e){

		var v = $j(this).val();
		v = $j.URLEncode(v);
		var span = $j(this).parents('ul.form').find('span.find-county');

		//if ($j(span).children('select').val() == 0) {
			$j(span).load('_assets/ajax.php?a=list-counties&state='+v+'&formname=_location_county');

		//}

	});

	$j("ul.form select[name$=location_state]").change();
	
	//$j("select[name=find_county]").change(function(e){
	//	$j("input[name=find_zipcode]").val('')
	//});
	
	$j('#sidebar2 .loc a.marker').click(function(e){
		e.preventDefault();
		var i = $j(this).attr('href');
		i = i.replace('#','');
		$j('#sidebar_map a:eq('+i+')').click();
	});
	
	// # Modal Window
	
	$j("a.modal").fancybox({
		
		//'modal' : true
		scrolling: 'no',
		
		autoScale: 'true'
	
	});
	
	
	// # Auto shadow application
	$j("h4").each(function (i) {
		$j(this).wrap('<div class="_shadow"></div>');
	});
	
	$j(".infobox").each(function (i) {
		$j(this).wrap('<div class="_shadow2"></div>');
	});
	
	$j(".volunteer li span").each(function (i) {
		$j(this).wrap('<div class="_shadow3"></div>');
	});
	
	var border = RUZEE.ShadedBorder.create({ corner:5, shadow:15 });
	
	$j("._shadow").each(function (i) {
		if ($j(this).attr("id") == "") {
			$j(this).attr("id","_shadow"+i);
		}		
		border.render($j(this).attr("id"));
	});
	
	$j("._shadow2").each(function (i) {
		if ($j(this).attr("id") == "") {
			$j(this).attr("id","_shadow2"+i);
		}		
		border.render($j(this).attr("id"));
	});
	
	$j("._shadow3").each(function (i) {
		if ($j(this).attr("id") == "") {
			$j(this).attr("id","_shadow3"+i);
		}		
		border.render($j(this).attr("id"));
	});
	
	if($j('#contact').length > 0) {
		var border4 = RUZEE.ShadedBorder.create({ corner:5, shadow:15 });
		border4.render('contact');	
	}
	
	$j('#flash2').delay(1000).queue(function () {
	
		//$j(this).load('_assets/ajax.php?a=flash');

		//$j(this).dequeue();
	});
		
});
