		google.load("jquery", "1.3.2");
	google.setOnLoadCallback(function() {
		launchWindow('#dialog2');
	
	//if close button is clicked
	$('#close, #cancelMail').click(function () {
		$('#mask').hide();
		$('.window').hide();
	});	
		
		$('#Sponsor1').data('tid', $('#Sponsor1').text());
		$('#Sponsor2').data('tid', $('#Sponsor2').text());
		 $('input[type="text"]').addClass("idleField"); 	 
     $('input[type="text"]').focus(function() {  
         $(this).removeClass("idleField").addClass("focusField");  
         if (this.value == this.defaultValue){  
             this.value = '';  
         }  
         if(this.value != this.defaultValue){  
             this.select();  
         }  
     });  
     
 $("#triggerSearch, #triggerSearch2, #triggerSearch3")
     .mouseover(function() {
     	$(this).addClass('highLighted');
     	$("#txtSearch").addClass('highLighted');
     })
      .mouseout(function() {
     	$(this).removeClass('highLighted');
     	$("#txtSearch").removeClass('highLighted');
     });
     $("#stateSearch, #stateSearch2, #stateSearch3, #stateSearch4")
     .mouseover(function() {
     	$(this).addClass('highLighted');
     	$("#cmbStates").addClass('highLighted');
     })
      .mouseout(function() {
     	$(this).removeClass('highLighted');
     	$("#cmbStates").removeClass('highLighted');
     });
     $("#storeSearch, #storeSearch2, #storeSearch3")
     .mouseover(function() {
     	$(this).addClass('highLighted');
     	$("#cmbStores").addClass('highLighted');
     })
      .mouseout(function() {
     	$(this).removeClass('highLighted');
     	$("#cmbStores").removeClass('highLighted');
     });
     $("#triggerInfo")
     .mouseover(function() {
     	$(this).addClass('highLighted');
     	$("#showScript").addClass('highLighted');
     })
      .mouseout(function() {
     	$(this).removeClass('highLighted');
     	$("#showScript").removeClass('highLighted');
     });
      $("#triggerStorePage")
     .mouseover(function() {
     	$(this).addClass('highLighted');
     	$("#sStore").addClass('highLighted');
     })
      .mouseout(function() {
     	$(this).removeClass('highLighted');
     	$("#sStore").removeClass('highLighted');
     });
      $("#triggerArrow")
     .mouseover(function() {
     	$(this).addClass('highLighted');
     	$("#uGeneric").addClass('highLighted highLightBorder');
     	$("#uBrand").addClass('highLighted highLightBorder');
     })
      .mouseout(function() {
     	$(this).removeClass('highLighted');
     	$("#uGeneric").removeClass('highLighted highLightBorder');
     	$("#uBrand").removeClass('highLighted highLightBorder');
     });
      $("#triggerInfoPage")
     .mouseover(function() {
     	$(this).addClass('highLighted');
     	$("#rGeneric").addClass('highLighted highLightBorder');
     	$("#rBrand").addClass('highLighted highLightBorder');
     })
      .mouseout(function() {
     	$(this).removeClass('highLighted');
     	$("#rGeneric").removeClass('highLighted highLightBorder');
     	$("#rBrand").removeClass('highLighted highLightBorder');
     });
     $("#triggerSponsors")
     .mouseover(function() {
     	$(this).addClass('highLighted');
     	$("#Sponsor1").addClass('highLighted highLightBorder');
     	$("#Sponsor2").addClass('highLighted highLightBorder');
     })
      .mouseout(function() {
     	$(this).removeClass('highLighted');
     	$("#Sponsor1").removeClass('highLighted highLightBorder');
     	$("#Sponsor2").removeClass('highLighted highLightBorder');
     });
     $('input[type="text"]').blur(function() {  
         $(this).removeClass("focusField").addClass("idleField");  
         if ($.trim(this.value == '')){  
             this.value = (this.defaultValue ? this.defaultValue : '');  
         }  
     }); 
		
		$("li.menu").click(function(){
			alert('Sorry,The menu has not been activated yet.');
		});
		$("#emailReport, #emailReport2").click(function() {
			var id = "#dialog";
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(2000); 
			//alert(mailz);
			//alert('Sorry, this function is not available yet');
		});
		
		$("#btnMail").click(function() {
			var emailRegEx = /^([a-zA-Z0-9_+\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			var mailScript = new Object();
			mailScript.store = $("#hStoreID").val();
			mailScript.state = $("#hStateID").val();
			mailScript.qsearch = $("#txtSearch").val();
			mailScript.qemail = $('#txtEmail').val();
			//mailScript.qmailfrom = $("#txtYourName").val();
			mailScript.qmailto = $("#txtTheirName").val();
			//alert(mailScript.state);
			//var mailz = scriptReport(store, state,qemail,qmailto,qmailfrom,qsearch);
			if(mailScript.qemail.match(emailRegEx)){
				var mailz = scriptReport2(mailScript);
				alert(mailz);
				$('#mask').hide();
				$('.window').hide();
			}else{
				alert('Please enter a valid email address.');
				//return false;
			}
		});
		
		$("li.menuz").click(function(){
			var menuLabel = $(this).text();
			
			if(menuLabel != 'Med Search'){
				$('#app').removeClass('showMe').addClass('noShow');
				$('#blog').removeClass('noShow').addClass('showMe');	
				var urly = $(this).attr('Earl');
				if(urly != ''){
					$("#blog").load(urly);
				}
				else{
					var content = $(this).attr('Content');
					$("#blog").html(content);
				}		
				$(this).text('Med Search');
			}
			else {
				$('#blog').removeClass('showMe').addClass('noShow');
				$('#app').removeClass('noShow').addClass('showMe');
				var placeName = $(this).data('tid');
				$(this).text(placeName);
				
			};
		})
		passURL = function(passed) {
		var sTerm = $("#txtSearch").val();
		if(sTerm != ''){
			passed = passed + "?txtSearch=" + sTerm;
		}
		ColdFusion.navigate(passed);
		} 
		     $('#uGeneric, #uBrand').click(function() {
     	var gen =  $(this).prev().text();
     	gen = $.trim(gen);
     	$('#txtSearch').val(gen);
     	ColdFusion.Grid.refresh('gridDrugs');
     });
       $('#sGeneric, #sBrand').click(function() {
     	var gen =  $(this).text();
     	gen = $.trim(gen);
     	$('#txtSearch').val(gen);
     	ColdFusion.Grid.refresh('gridDrugs');
     });
     //Research Drug Function
     $('#rGeneric, #rBrand').click(function() {
     	var gen =  $(this).prev().prev().text();
     	result = gen.split(" ");
     	alink = 'http://www.drugs.com/search.php?searchterm=' + result[0] ;
     	window.open(alink);
     });
     $('#theGrid').click(function(){
     	var thirty = $('#sThirty').text();
     	var ninety = $('#sNinety').text();
     	if(thirty == 0){
     		$('#sThirty').text('N/A')
     	}
     	else {
     		sthirty = '$' + thirty;
     		$('#sThirty').text(sthirty);
     	}
     	if(ninety == 0){
     		$('#sNinety').text('N/A');
     	}
     	else {
     		sninety = '$' + ninety;
     		$('#sNinety').text(sninety);
     	}
     	$("#triggerState")
     .mouseover(function() {
     	$(this).addClass('highLighted');
     	$("#cmbStatez").addClass('highLighted');
     })
      .mouseout(function() {
     	$(this).removeClass('highLighted');
     	$("#cmbStatez").removeClass('highLighted');
     });
     });
	});
	
	function launchWindow(id) {
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height());
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(2000); 
}

scriptReport2 = function(itm) {
	var CFC = new drugg();
	var Scripted = CFC.ScriptsTable2(itm);
	return Scripted;
	//alert(itm);
	//return true;
}
setStoreID = function() {
	var iStoreID = document.getElementById("cmbStorez").value;
	if(iStoreID== 'Select a store to limit results') {
		iStoreID = 0;
	}
	document.getElementById('hStoreID').value = iStoreID;
	ColdFusion.Grid.refresh('gridDrugs');
	}
	send2Search = function() {
 		var st = $("#spanBrand").text();
 		alert(st);
 	} ;
 	setStateID = function() {
	var iStateID = document.getElementById("cmbStatez").value;
	if(iStateID== 'Select a state to limit results') {
		iStateID = 0;
	}
	document.getElementById('hStateID').value = iStateID;
	ColdFusion.Grid.refresh('gridDrugs');
	}
	