// JavaScript Document
jQuery(document).ready(function() {
								
   //campaignDetails is on manageAccount.php page
   $('#campaignDetails').hide();
      
	//$("#panels #header #headerBottom #headerBottomContent .bigButton1 .bigButtonImg").hover(function() {
   $(this).find('.bigButtonImg').hover(function() {
		 //alert("in big button 1. position: " + $(this).position().left);
		 //$(this).css('left', $(this).position().left + 25); 
		 $(this).width($(this).width() + 30);
   },function(){
		 //$(this).css('left', $(this).position().left - 25); 
		 $(this).width($(this).width() - 30);
   });
      
/*   $("#panels #header #headerBottom #headerBottomContent .bigButton2 .bigButtonImg").hover(function() {
		 //alert("in big button 1. position: " + $(this).position().left);
		 //$(this).css('left', $(this).position().left + 25); 
		 $(this).width($(this).width() + 30);
   },function(){
		//$(this).css('left', $(this).position().left - 25); 
		$(this).width($(this).width() - 30);
   });
*/   
   $("#panels #header #headerTop #signinBox input#username").focus(function () {      
		$(this).removeClass("fadedText")
			   .val("");
	});
   
   $("#panels #header #headerTop #signinBox input#pswrd").focus(function () {      
		$(this).removeClass("fadedText")
			   .val("");
	});
   
   $(this).find('.statusBlock').click(function () {
		$(this).next('div .hintBox').toggle();		
	});
   
/*   $(this).find('.statusBlock').hover(function() {
		 $(this).next('div .hintBox').show();
		 //alert("hovering");
   },function(){
		 $(this).next('div .hintBox').hide();
   });
*/   
   
   //$(this).find('#searchInput').mouseover(function() {
/*   $('input#searchInput').keypress(function() {
		 $('div#searchResults').css("visibility","visible");
		 alert('blah');
   });
*/      

   $('input#searchInput').keypress(function() {
		 $('div#searchResults').css("visibility","visible");
		 alert('blah');
   });
      

   $('#participantsList').hover(function () {
		$(this).css({'cursor':'pointer'}); 
		},       
		function () {
			$(this).css({'cursor':'default'}); 
		});
	
   $("#bodyPanel #mainContent #search input#searchFirstName").focus(function () {      
		$(this).removeClass("emptySearhField")
			   .val("");
	});

   $("#bodyPanel #mainContent #search input#searchLastName").focus(function () {      
		$(this).removeClass("emptySearhField")
			   .val("");
	});

   $("#bodyPanel #mainContent #search input#searchCode").focus(function () {      
		$(this).removeClass("emptySearhField")
			   .val("");
	});      
   
});

//AUTO COMPLETE SCRIPT - BEGIN - used to search for campagin pages

function lookup(inputString) {
//alert("in string: " + inputString);	
	if(inputString.length == 0) {
		// Hide the suggestion box.
		$('#suggestions').hide();
	} else {
		$.post("/includes/autoCompleteParticipant.php", {queryString: ""+inputString+""}, function(data){
			if(data.length >0) {
				$('#suggestions').show();
				$('#autoSuggestionsList').html(data);
			}
		});
	}
} // lookup

function fill(thisValue, thisID) {
	$('#inputString').val(thisValue);
    $('#suggestions').hide();
    $('#selectedID').val(thisID);	

	$.post("/includes/displayMinPartInfo.php", {queryString: ""+thisID+""}, function(data){
		if(data.length >0) {
			$('#participantDisplay').append(data);
			$('#participantDisplay').show();
		}
	});
}	

function findAll(thisValue, accountid, roletypeid)
{
    $('#suggestions').hide();
	$.post("/includes/findMoreParticipants.php", {queryString: ""+thisValue+""}, function(data){
		if(data.length >0) {
			$('#participantsList').html(data);
			$('#participantsList').show();
		}
	});
}

//AUTO COMPLETE SCRIPT - END		

//show campaign details in the manage accounts page
function showCampaignDetails(thisID, pID)
{
   //run campaign details for a specific campaign and display in the #campaignDetails div
   
	$.post("/includes/campaignDetails.php", {queryString: ""+thisID+"", partID: ""+pID+""}, function(data){
		if(data.length >0) {
			$('#campaignDetails').html(data);
			$('#campaignDetails').slideDown();
		}
	});		
}

function hideCampaignDetails()
{
   $('#campaignDetails').slideUp();	
}
   
function shadeCampaignDetails()
{
	$('#campaignDetails').css("background-color","#CCC");
}

function hidePageSetup()
{
	//if(cbx.checked==1)
		$('#pagesetup').hide();
		//alert('in hide');
	//else
	//	$('#pagesetup').show();
}

function setPageSetup(rdo)
{
	//alert("radio: " + rdo.value);
	if(rdo.value=="nocampaign")
		$('#pagesetup').hide();
	else
		$('#pagesetup').show();
}

//when user selects an ad type on the addAd.php page, display the details of the at type selected
//ad_type_id and selectionDetailAd is on the addAd.php page
function showDetail(divID, details)
{
   document.getElementById(divID).innerHTML = details;
}

//used in addAd.php to determine whether to display the fields to allow user to add copy to his ad
function manageCopyFields(myAdType, myDisplaySetting)
{
	var adTitle = document.getElementById('ad_title_row');
	var adText = document.getElementById('ad_text_row');
	var copyDisplay = myDisplaySetting;
//alert('in manage copy fields. copyDisplay: ' + copyDisplay);

	adTitle.style.display = copyDisplay;
	adText.style.display = copyDisplay;	
}

