/*************************************************************************
   
 _____                      ____                           
|_   _|__  __ _ _ __ ___   |  _ \ _ __ ___ _ __ ___   __ _ 
  | |/ _ \/ _` | '_ ` _ \  | |_) | '__/ _ \ '_ ` _ \ / _` |
  | |  __/ (_| | | | | | | |  __/| | |  __/ | | | | | (_| |
  |_|\___|\__,_|_| |_| |_| |_|   |_|  \___|_| |_| |_|\__,_|
                                                       
	   ImagesForArt Controller. July 30th 2011 
	   Mike and Stephie 

**************************************************************************/
$(document).ready(function()
{
	

   ////////// create variables for each image and put them in the divs
   var iconDiv='<div class="icons" style="width:100% height:32px">icon div</div>';
   var emailImg='<img class="emailIcon" src="http://www.imagesforart.com/c5/files/8613/0665/1846/email_icon.jpg"/>';
   var cartImg='<img class="cartIcon" src="http://www.imagesforart.com/c5/files/5213/1009/2883/shopping_cart.jpg"/>';
   var btsImg='<img id="btsIcon" src="http://www.imagesforart.com/c5/files/5213/0665/1516/clapboard_icon.jpg"/>';
   
   $(".imageSearch_detail_Description").after(iconDiv);
   $(".icons").html(emailImg).append(cartImg);
   
   // styles for email and cart Icons
   $(".cartIcon").css("padding-right","4px");
   $(".emailIcon").css("padding-right","4px");

   // make the cursor into hand (pointer) on mouseover of email or cart Icon
   $(".cartIcon, .emailIcon").mouseover(function()
   {
   	    $(this).css("cursor","hand");
        $(this).css("cursor","pointer");
   });

	/*************************************************
		Referral toolbar controller  - Find-It Screen 
		August 27th 2011
	****/
	var catalogUrl="";
	// Take me to cart 
	$(".cartIcon").click(function()
	{
		  var catalogPath=$(this).closest(".photo-list-item").find(".imageSearch_title").text();
		  rgx = new RegExp(" ", "g");
		  catalogPath = catalogPath.toLowerCase();
		  catalogPath = catalogPath.replace(rgx, "-");
		  //alert(catalogPath);
		  catalogUrl='http://www.imagesforart.com/c5/catalog/' + catalogPath;
		  window.open(catalogUrl);
		
	 }); 
	// Take me to share with friend form and insert the link in textarea
	$(".emailIcon").click(function()
	{
			var catalogPath=$(this).closest(".photo-list-item").find(".imageSearch_title").text();
			rgx = new RegExp(" ", "g");
			catalogPath = catalogPath.toLowerCase();
			catalogPath = catalogPath.replace(rgx, "-");
			//alert(catalogPath);
			catalogUrl='http://www.imagesforart.com/c5/catalog/' + catalogPath;
			var shareURL="http://www.imagesforart.com/c5/share-it"+"?"+catalogUrl;
			// Open Share-It URL
			window.open(shareURL);
	});
	
	
	/************
	* When we get to the form
	**/
	var catalogSwitch="displayOnly";
	// get the url of the filtered images and add it after the message to friend in the textarea called mail_content (added 28th August)
	var thisURL=window.location.href;
	// Separate URL from args
	var urlSplit=thisURL.split("?");
	// Add link to message
	var messageText=$('textarea[name$="mail_content"]').text();
	// Rewrite message
	$('textarea[name$="mail_content"]').text(messageText+"\n\n"+urlSplit[1]+"?mode="+catalogSwitch);

$(".fieldCol").hide();
$(".fieldKeywords").click(function()
{
  $(".hiddenKeywords").show();
});
$(".fieldOrientation").click(function()
{
    $(".hiddenOrientation").show();
});
$(".fieldColour").click(function()
{
    $(".hiddenColour").show();
});
$(".fieldTemperature").click(function()
{
    $(".hiddenTemperature").show();
});
$(".fieldMood").click(function()
{
    $(".hiddenMood").show();
});
$(".fieldSeason").click(function()
{
    $(".hiddenSeason").show();
});
$(".fieldLocation").click(function()
{
    $(".hiddenLocation").show();
});
$(".fieldPhotographer").click(function()
{
    $(".hiddenPhotographer").show();
});
$(".fieldAlbum").click(function()
{
    $(".hiddenAlbum").show();
});
$(".fieldSaleable").click(function()
{
    $(".hiddenSaleable").show();
});
});


