String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
	
function addCat(id) {
	var obj = document.getElementById('addCat');
	
	if (obj.title.trim() == 'Add To Favorites') {
		
		$(obj).fadeOut('slow', function() {
			
			// GET COOKIE IF EXISTS 
			$.ajax({
			   	type: "POST",
			   	url: "~SITE/Layout/ajax/ajax_addtofav.cfm",
			   	data: 'id=' + id,
			   	success: function(msg){
			   	}
			});
			
			obj.title = 'Remove From Favorites'
			obj.innerHTML = '<img src="~ASSETS/IMG/layout/favorite_remove.jpg" border="0" align="absbottom" alt="Remove From Favorites" /> remove from My Favorite Felines';
			$(this).fadeIn('slow');
		});
		
	}
	else {
		$(obj).fadeOut('slow', function() {
			
			// REMOVE COOKIE IF EXISTS 
			$.ajax({
			   	type: "POST",
			   	url: "~SITE/Layout/ajax/ajax_removefromfav.cfm",
			   	data: 'id=' + id,
			   	success: function(msg){
					
			   	}
			});
			
			obj.title = 'Add To Favorites'
			obj.innerHTML = '<img src="~ASSETS/IMG/layout/favorite_add.jpg" border="0" align="absbottom" alt="Add To Favorites" /> add to My Favorite Felines';
			$(this).fadeIn('slow');
		});
		
	}
	
	return false;
}

function kitten(page,doo) {
	var obj = document.getElementById('kp');
	
	$(obj).fadeOut('slow', function() {
		$.ajax({
		   	type: "POST",
		   	url: "~SITE/Layout/dsp_kittens.cfm?do=" + doo,
		   	data: 'kp=' + page,
		   	success: function(msg){
				$(obj).html(msg);
				$(obj).fadeIn('slow');
		   	}
		});
	});
	
	return false;
}

function cat(page,doo) {
	var obj = document.getElementById('cp');
	
	$(obj).fadeOut('slow', function() {
		$.ajax({
		   	type: "POST",
		   	url: "~SITE/Layout/dsp_cats.cfm?do=" + doo,
		   	data: 'cp=' + page,
		   	success: function(msg){
				$(obj).html(msg);
				$(obj).fadeIn('slow');
		   	}
		});
	});
	
	return false;
}

function whatsThis() {
	// Calculate the page width and height 
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    } 

	document.getElementById('transBackground').style.display = 'block';
	document.getElementById('transBackground').style.height = pageHeight;
	document.getElementById('popUpBody').innerHTML = 'Your Favourite Felines allows you to book mark the top ten vokra cats and kittens that you like the best. If you decide to apply to adopt one or more vokra cats your Felines will automatically be listed on your application form. When you visit the VOKRA gallery start page you will see your top ten cats and kittens listed in the right sidebar and when you visit one of the specific galleries you will see your Felines in the image bar at the bottom of the page.';
	var obj = document.getElementById('popUpWindow');
	
	//request data for centering
	var windowWidth = $(window).width();
	var windowHeight = $(window).height(); 

	var popupHeight = $(obj).height();
	var popupWidth = $(obj).width();

	obj.style.position = 'absolute';
	obj.style.top = windowHeight/2-popupHeight/2+'px';
	obj.style.left = windowWidth/2-popupWidth/2+'px';
	obj.style.display = 'block';
	
	return false;
}

function specialNeeds() {
	// Calculate the page width and height 
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    } 

	document.getElementById('transBackground').style.display = 'block';
	document.getElementById('transBackground').style.height = pageHeight;
	document.getElementById('popUpBody').innerHTML = 'The cats in this category have a variety of special needs and requirements. Although we do sometimes have cats with physical special needs, most of the kitties on this page just require a quiet household with kind and patient people.';
	var obj = document.getElementById('popUpWindow');
	
	//request data for centering
	var windowWidth = $(window).width();
	var windowHeight = $(window).height(); 

	var popupHeight = $(obj).height();
	var popupWidth = $(obj).width();

	obj.style.position = 'absolute';
	obj.style.top = windowHeight/2-popupHeight/2+'px';
	obj.style.left = windowWidth/2-popupWidth/2+'px';
	obj.style.display = 'block';
	
	return false;
}

function closeWindow(){
	document.getElementById('transBackground').style.display = 'none';
	document.getElementById('popUpWindow').style.display = 'none';
	
	return false;
}
