//Flickr Widget in Sidebar			

$(document).ready(function(){		 			   
	// Our very special jQuery JSON fucntion call to Flickr, gets details of the most recent images			   
	$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?id=52617155@N08&lang=en-us&format=json&jsoncallback=?", displayImages);   //YOUR IDGETTR GOES HERE
	function displayImages(data) {																																   
		// Randomly choose where to start. A random number between 0 and the number of photos we grabbed (20) minus  7 (we are displaying 7 photos).
		var iStart = Math.floor(Math.random()*(0));	
		
		// Reset our counter to 0
		var iCount = 1;								
		
		// Start putting together the HTML string
		var htmlString = "<ul>";					
		
		// Now start cycling through our array of Flickr photo details
		$.each(data.items, function(i,item){
									
			// Let's only display 6 photos (a 2x3 grid), starting from a the first point in the feed				
			if (iCount > iStart && iCount < (iStart + 7)) {
				
				// I only want the ickle square thumbnails
				var sourceSquare = (item.media.m).replace("_m.jpg", "_s.jpg");		
				
				// Here's where we piece together the HTML
				htmlString += '<li><a href="' + item.link + '" target="_blank">';
				htmlString += '<img src="' + sourceSquare + '" alt="' + item.title + '" title="' + item.title + '"/>';
				htmlString += '</a></li>';
			}
			// Increase our counter by 1
			iCount++;
		});		
		
	// Pop our HTML in the #images DIV	
	$('#images').html(htmlString + "</ul>");
	
	// Close down the JSON function call
	}
	
// The end of our jQuery function	
});


//Flickr Widget in Footer			

$(document).ready(function(){		 			   
	// Our very special jQuery JSON fucntion call to Flickr, gets details of the most recent images			   
	$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?id=52617155@N08&lang=en-us&format=json&jsoncallback=?", displayImages);  //YOUR IDGETTR GOES HERE
	function displayImages(data) {																																   
		// Randomly choose where to start. A random number between 0 and the number of photos we grabbed (20) minus  7 (we are displaying 7 photos).
		var iStart = Math.floor(Math.random()*(0));	
		
		// Reset our counter to 0
		var iCount = 1;								
		
		// Start putting together the HTML string
		var htmlString = "<ul>";					
		
		// Now start cycling through our array of Flickr photo details
		$.each(data.items, function(i,item){
									
			// Let's only display 6 photos (a 2x3 grid), starting from a the first point in the feed				
			if (iCount > iStart && iCount < (iStart + 10)) {
				
				// I only want the ickle square thumbnails
				var sourceSquare = (item.media.m).replace("_m.jpg", "_s.jpg");		
				
				// Here's where we piece together the HTML
				htmlString += '<li><a href="' + item.link + '" target="_blank">';
				htmlString += '<img src="' + sourceSquare + '" alt="' + item.title + '" title="' + item.title + '"/>';
				htmlString += '</a></li>';
			}
			// Increase our counter by 1
			iCount++;
		});		
		
	// Pop our HTML in the #images DIV	
	$('#imagesfooter').html(htmlString + "</ul>");
	
	// Close down the JSON function call
	}
	
// The end of our jQuery function	
});

//Transparency Adjustments
$(document).ready(function() {  
            $('.transparent').each(function() {
                $(this).hover(
                    function() {
                        $(this).stop().animate({ opacity: 0.5 }, 400);
                    },
                   function() {
                       $(this).stop().animate({ opacity: 1.0 }, 400);
                   })
                });
});


//Start of Overlay Icons
$(document).ready(function(){   
    $("a.fancylightbox").append("<span></span>"); 
    $("a.fancylightbox").hover(function(){ 
        $(this).children("span").stop(true, true).fadeIn(0); 
    },function(){ 
        $(this).children("span").stop(true, true).fadeOut(0); 
    }); 
});
$(document).ready(function(){ 
    $("a.videolightbox").append("<span></span>"); 
    $("a.videolightbox").hover(function(){ 
        $(this).children("span").stop(true, true).fadeIn(0); 
    },function(){ 
        $(this).children("span").stop(true, true).fadeOut(0); 
    }); 
});
$(document).ready(function(){ 
    $("a.blogpost").append("<span></span>"); 
    $("a.blogpost").hover(function(){ 
        $(this).children("span").stop(true, true).fadeIn(0); 
    },function(){ 
        $(this).children("span").stop(true, true).fadeOut(0); 
    }); 
});

function toggle(toggleDivName, displayTag) {
	var ele = document.getElementById(toggleDivName);
	var text = document.getElementById(displayTag);
	if(ele.style.display == "block") {
    		ele.style.display = "none";
		text.innerHTML = "More >";
  	}
	else {
		ele.style.display = "block";
		text.innerHTML = "< Less";
	}
}

function goToSearchResults() {
    var searchText = $("#searchbox").attr("value");
    window.open("/search/search.php?query=" + escape(searchText) + "&search=1", "_self");
}

//Homepage News Scroller
var currentNewsDivID = 1;
var totalNewsDivs = 3;

function changeNewsDivPrevious() {
	var idToShow;
	if (currentNewsDivID == 1) {
		idToShow = totalNewsDivs;
	} else {
		idToShow = currentNewsDivID - 1;
	}
	$("#news" + currentNewsDivID).fadeOut(0);
	$("#news" + idToShow).fadeIn(0);
	currentNewsDivID = idToShow;
}

function changeNewsDivNext() {
	var idToShow;
	if (currentNewsDivID == totalNewsDivs) {
		idToShow = 1;
	} else {
		idToShow = currentNewsDivID + 1;
	}
	$("#news" + currentNewsDivID).fadeOut(0);
	$("#news" + idToShow).fadeIn(0);
	currentNewsDivID = idToShow;
}

//Form Validation
function Validate(frm){
        if (Trim(frm.first_name.value).length == 0){
            alert("First Name is a required field.");
            frm.first_name.focus();
            return false;
        }
        if (Trim(frm.last_name.value).length == 0){
            alert("Last Name is a required field.");
            frm.last_name.focus();
            return false;
        }
        if (Trim(frm.title.value).length == 0){
            alert("Title is a required field.");
            frm.title.focus();
            return false;
        }
		if (Trim(frm.company.value).length == 0){
            alert("Company is a required field.");
            frm.company.focus();
            return false;
        }
        if (Trim(frm.email.value).length == 0){
            alert("E-mail is a required field.");
            frm.email.focus();
            return false;
        } else if (Trim(frm.email.value).indexOf("@") < 0){
            alert("E-mail must be in me@mydomain.com format.");
            frm.email.focus();
            return false;
        }
        if (Trim(frm.phone.value).length == 0){
            alert("Phone is a required field.");
            frm.phone.focus();
            return false;
        }
        if (Trim(frm.state.value).length == 0){
            alert("State is a required field.");
            frm.state.focus();
            return false;
        }

        frm.action = "https://salesforce.ringlead.com/cgi-bin/1283/1/dedup.pl";
       
        return true;
           }
   
        function Trim(sVal) {
        sVal = LTrim(sVal);
        return RTrim(sVal);
        }

        function RTrim(sVal) {
        while(sVal.charAt((sVal.length - 1)) == " ")    {
        sVal = sVal.substring(0, sVal.length - 1);
        }
        return sVal;
        }

        function LTrim(sVal) {
        while(sVal.charAt(0) == " ") {
        sVal = sVal.replace(sVal.charAt(0), "");
        }
        return sVal;
        }

