

//Name this file the same lines as the Component
//
// part of this file takes care of the phplist - adding an email
//
// active:
//make sure there is an "active" attribute in the SQL database o type: meta boolean string
//make sure the url: 'cms-press', is set in the activate () function		

$j(document).ready(function() {
	
	// ===================== FANCY BOX ================================
	$j('a#photos_trigger').fancybox({
		zoomSpeedIn: 	0,
		zoomSpeedOut: 	0,
		overlayShow:	true,
		frameWidth: 	660,
		frameHeight: 	480
	});
	
	
	$j('a#signup_trigger').fancybox({
		zoomSpeedIn: 	0,
		zoomSpeedOut: 	0,
		overlayShow:	true,
		frameWidth: 	300,
		frameHeight: 	390
	});

	if ($j.browser.msie) {
		$j('#fancy_wrap').pngFix();
	}
	
	//this is for the more button in the featured section
	var length = $j('ul.featuresCol').length;
	if (length > 1) $j('a.featuresNav').show();
	
	$j('a.featuresNav').click(function() {
	
		var position = $j('.featuresSlide').position().left - 170;
		var num = length * (-170);
		//alert(position);
		//alert(num);
		
		if (position > num) {
			$j('.featuresSlide').animate({ left: '-=170px' });
		}
		
		if (position <= num) {
			$j('.featuresSlide').animate({ left: '0px' });
		}
	
		return false;
	
	});

	$j('.homeMiddleTabs a').click(function() {
		$j('div.tab').filter(this.hash).show().siblings('div.tab').hide();
		$j(this).addClass('active').parent('span').siblings('span').find('a').removeClass('active');
		return false;
	}).filter(':first').click();

	
	// ===================== AJAX PHOTO FILE UPLOAD ================================
	var options = { 
	       // target:        '#output1',   // target element(s) to be updated with server response 
	        beforeSubmit:  showRequest,  // pre-submit callback 
	        error:		   showResponse,
			type:      	   "POST",
	        success:       showResponse  // post-submit callback 
	 
	        // other available options: 
	        //url:       url         // override for form's 'action' attribute 
	        //type:      type        // 'get' or 'post', override for form's 'method' attribute 
	        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
	        //clearForm: true        // clear all form fields after successful submit 
	        //resetForm: true        // reset the form after successful submit 
	 
	        // $.ajax options can be used here too, for example: 
	        //timeout:   3000 
	    }; 
			
		$j('a#signup_trigger').click(function() {
			$j('.upload_response_error').hide();
			$j('.upload_response_success').hide();
			$j('.upload_progress').hide();
			$j($j('.wufull').get(1)).bind('submit', function() {
				$j(this).ajaxSubmit(options);
				return false;	
			});//
		});
});
	 
// pre-submit callback 
function showRequest(formData, jqForm, options) { 
    $j('.upload_progress').show();
    return true; 
} 
 
// post-submit callback 
function showResponse(responseText, statusText)  { 
	if(responseText == '1') {
		$j('.upload_progress').hide();
		$j('.upload_response_success').show().animate({opacity:1},1500).fadeOut(500);	
	} else {
		$j('.upload_progress').hide();
		$j('.upload_response_error').show().animate({opacity:1},1500).fadeOut(500);	
	}
} 


//this displays a success or failure message when an update on the list is performed
function messageDisplay() {
	$j('#refreshmsg').show().animate({opacity:1},1500).fadeOut(500);	
}



