		Shadowbox.init();

            	//Declaration of a gload javascript variable
            	var refreshId;
	    	var sound;

		/*refreshId1 = setInterval(function() {
			rotateBanner();
                                     }, 15000);*/

                //Load some items once the page is 100% loaded
		$(document).ready(function() {
			
			//Hide all those divs by default
			$('#vul_scan').hide();
			$('#web_scan').hide();
                        $('#advanced').hide();

			//This is a listener to see if the close button is pressed
			/*$("a#close_ad").click(function(){
                                $("div#box").hide();
                	});*/
			
			//Make a couple of clicks actions based on what they chose
			$('#show_advanced').click(function() {
				$('#vul_scan').hide('slow', function() {
					// Animation complete.
				});
				
				$('#web_scan').hide('slow', function() {
					// Animation complete.
				});
                                $('#advanced').show('slow', function() {
					// Animation complete.
				});
                                $('#scan_info').val("<?php echo $_SERVER['REMOTE_ADDR']; ?>");
			});
			
			$('#show_vuln_scan').click(function() {
				$('#vul_scan').show('slow', function() {
					// Animation complete.
				});
				$('#web_scan').hide('slow', function() {
					// Animation complete.
				});
                                $('#advanced').hide('slow', function() {
					// Animation complete.
				});
				$('#scan_info').val("<?php echo $_SERVER['REMOTE_ADDR']; ?>");
				
			});
		
			$('#show_web_scan').click(function() {
				$('#web_scan').show('slow', function() {
				// Animation complete.
				});
				$('#vul_scan').hide('slow', function() {
					// Animation complete.
				});
                                $('#advanced').hide('slow', function() {
					// Animation complete.
				});
				$('#scan_info').val("htttp://");
			});

			$("#form2").submit(function() {
    			
				//$('#whois_button').html('<img src = "www.amihackerproof/images/105.gif" alt = "Loading" />');	
				$('#whois_button').text('Processing...');
				return true;	
			
			});

                        $("#whois").submit(function() {
                                
                                //$('#trace_button').html('<img src = "105.gif" alt = "Loading" />');
                                $('#trace_button').text('Processing...');
				return true;
                        
                        });


                        $("#form3").submit(function() {
                                
                                //$('#ping_button').html('<img src = "105.gif" alt = "Loading" />');
                                $('#ping_button').text('Processing...');
				return true;
                        
                        });


			//Change a icon if the buttom is clicked

			//Disable the button once it is clicked 
			$('#search_button').click(function() {

                            //Hide all of those panels
                            $('#vul_scan').hide();
                            $('#web_scan').hide();
                            $('#advanced').hide();
			    $('#report_type').hide();
			    $('#captcha_area').hide();
			    //$('#report_description').hide();

                            //$("#search_button").attr("disabled", "disabled");
                            startScan();
                            
			});



		$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)

		$("ul.topnav li span").click(function() { //When trigger is clicked...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
			});


			
		});
		
		function startScan()
		{

			//Check to see if the the IP address has been filled out
			/*if ($('#terms:checked').val() !== null)
			{
  				// Insert code here.
				alert("Please agree to your terms and agreements!");
				return false;	
			}*/	

			if ($('#terms').is(':checked')) 
			{  

			} 
			else 
			{ 
				alert("Please agree to the terms and agreements");
				$('#report_type').show();
				$('#captcha_area').show(); 
				return false; 
			}

	
			//Check to see if the report type has been selected
			if ( $('#selected_report').val() != ""  )
			{

				//Hide the search button
				//$('#search_button_area').html("We are about to start your scan.");
				$('#search_button_area').hide();


				//Get the value of the information
                            var ip_address = $('#scan_info').val();
                            //$('#scan_update').html("<center>Please wait while we while we perform your scan for " + ip_address + "<br /><img src = '103.gif' alt = 'Loading...' /></center>");

                            var first_name = $('#firstname').val();
                            var last_name = $('#lastname').val();
                            var address = $('#address').val();
                            var city = $('#city').val();
                            var state = $('#state').val();
                            var zip = $('#zip').val();
                            var email = $('#email').val();
                            var company = $('#company').val();
                            var phone = $('#phone').val();
                            var hear_about_us = $('#hear_about_us').val();
                            var report_type = $('#selected_report').val();
        		    var code = $('#code').val();
			    var scan_type = $('#scan_type').val();

                                //was vuln.php
                            $.post("quick_scan.php", { first_name: first_name, last_name: last_name, company: company, address: address, city: city, state: state,
                        zip: zip, email: email, phone: phone, ip_address: ip_address, hear_about_us: hear_about_us, report_type: report_type, code: code, scan_type: scan_type},
                               function(data){
                                     //alert("Data Loaded: " + data);
                                     //$('#scan_update').html(data);
                                     //Parse out the scan id from the json
                                     //var json_text = JSON.parse(data);
                                     var json_text = json_parse(data);
                                     var scan_id = json_text.scan_id;
				     var error_text = json_text.error;

				     //Check to see if the error was left empty
				    if ( error_text == "" )
				    {


                                        //alert("got the scan id")
                                     //Now that we have the can check every 3 seconds or something to see if the
                                     //scan has finished.
                                     $('#scan_update').html('<center><p>Please wait while we perform your scan!<br />Please DO NOT close this window/tab!<br /><img src = "103.gif" alt = "Loading..." /></p></center>');

					//Now play the sound that lets us know that the scan is starting
					//sound = $.sound.play("scancomplete.wav",{timeout:3000}); // Play a sound on mouse over

					//Updat the thing th show the button that will stop the music
					//$('#music_stop').html('<input type = "button" id = "stop_the_music" value = "Stop the Music" />');

					
					//Here is where we can show the
					//$("div#box").slideDown("slow");

					//Now start the timer so that the user can exit out the ad
					//adCountdown(); 
					

                                        //alert("Updated the information");
                                     refreshId = setInterval(function() {
                                      //$("#update_pane").load('get_scan_status_quick.php');
                                        checkScanStatus(scan_id);
                                     }, 15000);


					//Now call the 
					//retrieveInformation(address);

				    }
				    else
				    {

					//Alert that they have entered an invalid IP or web address
				        alert(error_text);	
					$('#search_button_area').show();
					$('#report_type').show();
					$('#captcha_area').show();


					//Also make the check it out button re appear
				    }

                                    // alert(scan_id);

                               });


			}
			else
			{
				alert("Please select a report type!");
				$('#report_type').show();
				$('#captcha_area').show();

			}


		}
		
                function checkScanStatus(id)
                {
                    //This function will check and see if the status of the scan
                    $.post("get_scan_status.php", { id: id},
			   function(data){
				 //alert("Data Loaded: " + data);
				 //$('#scan_update').append(data);
                                 $('#scan_update').html(data);

                                 //Check to see if the '~' is there if it is then
                                 //stop the refrest
                                 if  (data.charAt(0) == "~")
                                 {
                                    clearInterval(refreshId);
                                 }

				 //Parse out the scan id from the json
				 //var json_text = JSON.parse(data);
				 //var scan_id = json_text.scan_id;
				 //alert(scan_id);
				 //alert("got in");
			   });
                }
		
		//This function will send all of the information to the DB
		function sendInformation()
		{
			//Create some ajax to send all of the information to the DB
			//Get all of the information
			var first_name = $('#first_name').val();
			var last_name = $('#last_name').val();
			var address = $('#address').val();
			var city = $('#city').val();
			var state = $('#state').val();
			var zip = $('#zip').val();
			var ip_address = $('#ip_address').val();
			var hear_about_us = $('#hear_about_us').val();
			
			//Now validate
			
			//Finally go ahead and post them to the php file
			$.post("add_scan.php", { first_name: first_name, last_name: last_name , address: address, city: city, state: state,
			zip: zip, ip_address: ip_address, hear_about_us: hear_about_us},
			   function(data){
				 //alert("Data Loaded: " + data);
				 
				 //Parse out the scan id from the json
				 var json_text = JSON.parse(data);
				 var scan_id = json_text.scan_id;
				 alert(scan_id);
			   });
			   
			  

		}

		function getDescription()
		{

			//Get the information from the selected item
			var name = $('#selected_report').val();

			//AJAX to get the description
			$.post("get_report_description.php", { name: name},
				function(data){

				$('#report_description').html(data);

			});

		}

		function stopSound()
		{
			
			//This function will stop playing the sound when it is called
			//sound.remove();


		}
		function rotateBanner()
		{

			//Do some ajax and get the new banner
			$.post("https://www.amihackerproof.com/show_banner.php",
                                function(data){

                                $('#banner').html(data);

                        });

		}

		/*function adCountdown() {

		setTimeout(function() {
            		$('div#ad_text').html('Click <a href="#" id="close_ad">here to close...</a>');
        	}, 10000);

		}*/

		/*
 		function updateEmailAddress()
		{	
			//This function will update the email addresss that is in the databsase for the scan
			$.post("https://www.amihackerproof.com/updateEmailAddress.php",

				function(data){

				$('#').html(data);

			});
		}
  		*/

var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

function jsddm_open()
{	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}

function jsddm_close()
{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{	closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}

$(document).ready(function()
{	$('#jsddm > li').bind('mouseover', jsddm_open);
	$('#jsddm > li').bind('mouseout',  jsddm_timer);});

document.onclick = jsddm_close;

function showIPAddress()
{

	$.post("get_ip_address.php", { name: name},
                                function(data){

				alert("Your IP address is: " + data);
 
                        });

}

