$(document).ready(function(){ 
if($(".ProductList .ProductBox").length > 0){
		$(".ProductList .ProductBox").hover(
			function(){
				$(this).css({ borderColor:"#00457D"});
			}, 
			function () {
				$(this).css({ borderColor:"#cccccc"});
			}
		)
	}

if($("#searchinp").length > 0){
	$("#searchinp").focus(
		function(){
		  $("#searchinp").css({ borderColor:"#00457D", color:"#474747" });
	});
}


if($(".picshowsmall").length > 0){
	$(".picshowsmall").hover(
		  function () {
			$(this).addClass("hover");
		  }, 
		  function () {
			 $(this).removeClass("hover");
		  }
	);
}


if($(".picshowsmall img").length > 0){
	$(".picshowsmall img").click(
			function (){
				var mysrc = this.src;
				var picHolder = document.getElementById('picHolder');
				var imgCaption = document.getElementById('imgCaption');
				var targetImg = picHolder.childNodes[0];
				targetImg.src = "";
				targetImg.src = mysrc;
				imgCaption.innerHTML = this.alt;
	
			}
	);
}

function doIt(x){
	var option = x.selectedIndex;
	$(".form_section").hide("normal");
	//alert(option);
	if(option!=0){
		var optionExpando = document.getElementById('pay_option_'+option);
		if(optionExpando.style.display!="block"){
			$(optionExpando).show("normal");
		}
	}
}

if($("p[class='formRow'] input").length > 0 && $("input[readonly!='readonly']")){
		$("p[class='formRow'] input").focus(
			function(){
				$(this.parentNode).addClass("focused");
			}
		);
}

if($("p[class='formRow'] input").length > 0){
	$("p[class='formRow'] input").blur(
		function(){
			$(this.parentNode).removeClass("focused");
		}
	);
}

if($("p[class='formRow'] input").length > 0){
	$("p[class='formRow'] select").focus(
		function(){
			$(this.parentNode).addClass("focused");
		}
	);
}

if($("p[class='formRow'] input").length > 0){
	$("p[class='formRow'] select").blur(
		function(){
			$(this.parentNode).removeClass("focused");
		}
	);
}

if($("p[class='formRowNested'] input").length > 0){
	$("p[class='formRowNested'] input").focus(
		function(){
			$(this.parentNode.parentNode).addClass("focused");
		}
	);
}

if($("p[class='formRowNested'] input").length > 0){
	$("p[class='formRowNested'] input").blur(
		function(){
			$(this.parentNode.parentNode).removeClass("focused");
		}
	);
}

// ToolTip Component //
if($("a.tool-hover").length > 0) {
	  $("a.tool-hover").cluetip({local:true, arrows: true, showTitle: false, cursor: 'pointer', activation: 'hover'});
	}
	
if($("a.tool-hover-select").length > 0) {
	  $("a.tool-hover-select").hover(
      function () {
		var rel = $(this).attr("rel");
		var target = document.getElementById(rel);
		var targetText = target.innerHTML;
		var test = $("#hiddenHelp p").text();
		$("#hiddenHelp p").html(targetText);
		$("#hiddenHelp").slideDown("normal");
      }, 
      function () {
		$("#hiddenHelp").slideUp("normal");
      }
    );
}

});//end js

function init(){
	var targetCount = $(".details").length;
	var targetCount = targetCount - 1;
	for(i=0;i<targetCount;i++){
		$(".details").hide();
		$(".hide").hide();
	}	
}

if($(".membership").length > 0){
	$(".membership").click(function(){
		var myId = this.id;
		var myMembership = "#"+myId;
		var myDetails = "#"+myId+ " .details";
		var myPrice =  "#"+myId+ " .price";
		var myViewLink =  "#"+myId+ " .view";
		var myHideLink =  "#"+myId+ " .hide";
		var detailStatus = $(myDetails).css("display");
		
		if(detailStatus=='none'){
			$(myViewLink).fadeOut("fast");
			$(myHideLink).fadeIn("normal");
			$(myDetails).show("slow");
			$(myPrice).animate({ 
			top: "0px"
		  }, 500 );
			$(myMembership).animate({
			backgroundColor: "igsblue"
		  },500);
			return;
		}
		
		if(detailStatus!='none'){
			$(myHideLink).fadeOut("fast");
			$(myViewLink).fadeIn("normal");
			$(myDetails).hide("slow");
			$(myPrice).animate({ 
			top: "-35px"
		  }, 500 );
			$(myMembership).animate({
			backgroundColor: "white"
		  },500);
			return;
		}
		
		
		/*var myDetailsCount = $(myDetails).length;
		alert(myDetailsCount+" dynamic");
		var myDetailsInfo = $("#membership_1 .details").length;
		alert(myDetailsInfo+" hardcoded");*/
	});
}


	/*
function doMagic(ref){
	
	alert(ref.nodeName);	

	var mDetails = document.getElementById('detail_'+ref);
	var mBlock = document.getElementById('membership_'+ref);
	var pBlock = document.getElementById('price_'+ref);
	var viewLink = document.getElementById('view_'+ref);
	var hideLink = document.getElementById('hide_'+ref);
	*/
	/*
	if(mDetails.style.display=='none'){
		$(viewLink).fadeOut("fast");
		$(hideLink).fadeIn("normal");
		$(mDetails).show("slow");
		$(pBlock).animate({ 
        top: "0px"
      }, 500 );
		$(mBlock).animate({
		backgroundColor: "igsblue"
	  },500);
		return;
	}
	
	if(mDetails.style.display!='none'){
		$(hideLink).fadeOut("fast");
		$(viewLink).fadeIn("normal");
		$(mDetails).hide("slow");
		$(pBlock).animate({ 
        top: "-35px"
      }, 500 );
		$(mBlock).animate({
		backgroundColor: "white"
	  },500);
		return;
	}
}*/

