    function ShowIndexNews() {        
        var url = "rss.php";
        var returnstr = "";
		$.ajax({
			url: url,
			cache: false,
			timeout: 5000000,
			success: function(str) {
				ParseNews(str);
			},
			error: function(xhr) {
				str = 'Error||Communication Error: ' + xhr.status + ' ' + xhr.statusText;
				ParseNews(str);
			}
		});		
        return returnstr;
    }
	
    function ParseNews(str) {		
        var newsarray = str.split('\n');		
        var t = setTimeout(function(){
                ShowNewsItem(0,newsarray);
            },50);
    }	
    function ShowNewsItem(i,newsarray) {
        var newsdiv = "#news .desc";
        var newsitem = newsarray[i];
        i += 1;
        if (newsarray.length == i) {
            i = 0;
        }
        var newitemArray = newsitem.split('|');
		
		var img = '';
		if (newitemArray[0].search("Offer Spotlight") > -1) {
			img = '<img class="ico" src="/local/images/adfoundry_ico.gif"/>';
		}
		var tweet = newitemArray[0].replace('Offer Spotlight - ', '');
		tweet = tweet.replace('Offer Spotlights - ', '');
		
        var formatted = img +  '<span class="tweet">' + tweet + '<span class="time">' + newitemArray[1] + '</span></span>';
        $(newsdiv).fadeOut('slow',function(){
            $(newsdiv).html(formatted);
            $(newsdiv).fadeIn('slow', function(){
                    setTimeout(function(){
                        ShowNewsItem(i,newsarray);
                    },5000);
                });
        })
    }

$(document).ready(function(){
	
	$('.autofill').focus(function () {
		if ($.trim($(this).val()) == $(this).attr('default') )
		{
			$(this).val("");
			$(this).removeClass('inactive');
		}		
    });

	$('.autofill').blur(function() {		
		if ($.trim($(this).val()) == '')
		{
			$(this).val($(this).attr('default'));
			$(this).addClass('inactive');
		}
	});
	
    $("#submit").bind('click',function(event){
        $('.autofill').each(function(){
			if ($.trim($(this).val()) == $(this).attr('default') )
			{				
				$(this).val("");
			}
		});
    });
    $("#contactform").RSV({        
        customErrorHandler: ErrorHandle,
      rules: [
        "required,name,Name",
        "required,email,Email",        
        "valid_email,email,Email"
      ]
    });
    
    function ErrorHandle(f, errorInfo) {
        var message = "";
        for (var i=0; i<errorInfo.length; i++) {
              message += errorInfo[i][1] + ", ";
            }
        if (message == ""){
            $('#formError').hide();  
            form.submit();            
            return false;
        } else {
            $('#formError').html('<p>A valid ' + message + ' required.</p>');
            $('#formError').show();
			$('.autofill').each(function(){
				if ($.trim($(this).val()) == "" )
				{				
					$(this).val($(this).attr('default'));
					$(this).addClass('inactive');
				}
			});
            return false;
        }
    }
	
	$('.autofill').each(function(){
		if ($.trim($(this).val()) != $(this).attr('default') )
		{				
			$(this).removeClass('inactive');
		}
	});
});
