/* Author:Nik Martin
*/
function CheckAll(x)
{
    
if (ISBLANK(x.fieldnm_1.value)) 
	{ 	
		    alert("Please define value for Name field !!");
    	    return false;
    }

if (ISBLANK(x.fieldnm_2.value)) 
{ 	
	alert("Please enter Email field !!");
    return false;
}
if(checkemail(x.fieldnm_2.value)==false)
{
	alert("Please enter a valid email address for Email field !!");
	return false;
}

if (ISBLANK(x.fieldnm_4.value)) 
	{ 	
		    alert("Please define value for Comments field !!");
    	    return false;
    }

 
	 return true;
}

/// email check
function checkemail(myemail)
{
var str=myemail;
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
{
testresults=true
}
else
{
testresults=false
}
return (testresults)
}

/// to check that perticular value is EMPTY OR NOT
function ISBLANK(xx)
{ 
        var cc=0,tt;
		for(tt=0; tt<xx.length; tt++)
		{
		     if (xx.charAt(tt)==' ')
			 {
			 	cc=cc+1; // count blank character
			 }
		}
		if (cc==xx.length)
		{
			return true;  //// means it is BLANK
		}
	     return false;	//// means it is NOT BLANK
}

function is_radio_button_selected(fieldnm)
{
	// set var radio_choice to false
	var radio_choice = false;

	// Loop from zero to the one minus the number of radio button selections
	for (counter = 0; counter < fieldnm.length; counter++)
		{
		// If a radio button has been selected it will return true
		// (If not it will return false)
			if (fieldnm[counter].checked)
			radio_choice = true; 
		}

	if (!radio_choice)
		{
			return (false); /// means not selected
		}
	return (true); /// means selected
}

Date.prototype.getMonthName = function() {
   return ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'][this.getMonth()]; 
}


function _run() {
        /*
        * Retrieve a list of blog posts
        */
        
        // Obtain a reference to the 'content' div
        var content = document.getElementById('blognav');
        
        // Create the blogger service object
        var bloggerService =
            new google.gdata.blogger.BloggerService('com.appspot.interactivesampler');
        
        // The feed for a single blog. (In this case, the Official Google Blog.)
        //
        // The ID included in this URI can be retrieved from the
        // <link rel="service.post"> element in the Blog's HTML source
        var feedUri = 'http://blog.servercorps.com/feeds/posts/default';
        
        // A callback method invoked getBlogPostFeed() returns data
        var handleBlogPostFeed = function(postsFeedRoot) {
          var posts = postsFeedRoot.feed.getEntries();
          
          // This variable will buffer HTML output until function completes
          var html = '';
          
          // Display blog's title
          html += '<h3>Blog</h3>';
          
          // Display blog posts
          html += '<ul>';
          for (var i = 0; i<4;  i++) {
			var post = posts[i];
			
			var pubDate = post.getPublished().getValue();
			var d = new Date(pubDate.date);
			var postMonth = d.getMonthName().slice(0,3);
			var postDay = d.getDate();
            var postTitle = post.getTitle().getText();
            var postURL = post.getHtmlLink().getHref();
            html += '<li><a href="' + postURL + '" target="_blank">'
                      + postTitle
                      + '</a><div class="date"><span class="month">' 
                      + postMonth + '</span><span class="day">' 
                      + postDay + '</span></div></li>';
          }
          html += '</ul>';
          
          // Write out buffered HTML, and clear the "Loading..." message
          content.innerHTML = html;
        };
        
        var handleError = function(error) {
          content.innerHTML = '<pre>' + error + '</pre>';
        };
        
        bloggerService.getBlogPostFeed(feedUri, handleBlogPostFeed, handleError);
        
      }
      
	
	
	

