




function ajaxloader(divid){

	document.getElementById(divid).innerHTML = "<br><div style='width: 100px; margin-left: auto; margin-right: auto;'><img src='/images/ajax-loader.gif' style='border: 0;'></div><br>";
		
}


function searchtermopen2 (searchmid, mid, duration){

	



	cdiv = "termdataarea"+mid;
	chartdiv = "chartdiv"+mid;
	ajaxloader(chartdiv);

	//document.getElementById(searchmid).innerHTML = "";

	document.getElementById(cdiv).style.display = 'block'; 

	
	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=searchtermopen2&mid="+mid+"&duration="+duration,
                dataType: 'html',
                success: function display(data){

			document.getElementById(searchmid).innerHTML = data;


			ga_grapharray(mid, duration);

		}
            });


}


function searchtermopen4 (searchmid, mid, duration){

	



	cdiv = "termdataarea"+mid;
	chartdiv = "chartdiv"+mid;
	ajaxloader(chartdiv);

	//document.getElementById(searchmid).innerHTML = "";

	document.getElementById(cdiv).style.display = 'block'; 

	
	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=searchtermopen2&mid="+mid+"&duration="+duration,
                dataType: 'html',
                success: function display(data){

			document.getElementById(searchmid).innerHTML = data;


			ga_grapharray_pageviews(mid, duration);

		}
            });


}


function searchtermopen3 (searchmid, mid, duration){

	



	cdiv = "termdataarea"+mid;
	chartdiv = "chartdiv"+mid;
	ajaxloader(chartdiv);

	//document.getElementById(searchmid).innerHTML = "";

	document.getElementById(cdiv).style.display = 'block'; 

	
	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=searchtermopen2&mid="+mid+"&duration="+duration,
                dataType: 'html',
                success: function display(data){

			document.getElementById(searchmid).innerHTML = data;


			grapharray(mid, duration);

		}
            });


}



function ga_grapharray(mid, duration){

	chartdiv = "chartdiv"+mid;
	ajaxloader(chartdiv);

	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=ga_grapharray&mid="+mid+"&duration="+duration,
                dataType: 'script',
                success: function(data){

			//document.getElementById(searchmid).innerHTML = data;
			//alert("data = "+data);
		
			var dval = eval(data);
	
			//alert(dval[1]);

			//alert(dval[0]);


			d1 = eval(dval[0]);
			d2 = eval(dval[1]);

			if(d1 == ""){


				//alert("no DATA");

				//NO DATA YET
				nodatayet(mid);
			} else {

			
				//alert("getting past check");

	
				//$.jqplot('chartdiv',  [dval]);

				cdiv = "chartdiv"+mid;

				plot9 = $.jqplot(cdiv, [d1, d2], {
					//title:'Search Position',

				        legend:{show:true}, 
					series:[

						{label:'SERP Position', showMarker:false},
						{label:'GA Visits', yaxis:'y2axis', showMarker:false}, 
					],



					axes:{
						xaxis:{
							renderer:$.jqplot.DateAxisRenderer,
							rendererOptions:{tickRenderer:$.jqplot.CanvasAxisTickRenderer},

							pad:1,


							tickOptions:{
								formatString:'%b %#d, %Y', 
							    }


						},
						yaxis:{
							syncTicks:true,
							tickOptions:{formatString:'%.0f'}
						},
					        y2axis:{padMax:2} 
					},

					highlighter:{
						show: true,
						showMarker:true,
						sizeAdjust: 15,
						formatString:'<table class="jqplot_my_highlighter"><tr><td class="title">Date:</td><td class="data">%s</td></tr><tr><td class="title">Value:</td><td class="data">%s</td></tr></table>'

					}
				});
			}


		}
            });


	document.getElementById(chartdiv).innerHTML = "";

}



function ga_grapharray_pageviews(mid, duration){

	chartdiv = "chartdiv"+mid;
	ajaxloader(chartdiv);

	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=ga_grapharray&type=pv&mid="+mid+"&duration="+duration,
                dataType: 'script',
                success: function(data){

			//document.getElementById(searchmid).innerHTML = data;
			//alert("data = "+data);
		
			var dval = eval(data);
	
			//alert(dval[1]);

			//alert(dval[0]);


			d1 = eval(dval[0]);
			d2 = eval(dval[1]);

			if(d1 == ""){


				//alert("no DATA");

				//NO DATA YET
				nodatayet(mid);
			} else {

			
				//alert("getting past check");

	
				//$.jqplot('chartdiv',  [dval]);

				cdiv = "chartdiv"+mid;

				plot9 = $.jqplot(cdiv, [d1, d2], {
					//title:'Search Position',

				        legend:{show:true}, 
					series:[

						{label:'SERP Position', showMarker:false},
						{label:'GA Page Views', yaxis:'y2axis', showMarker:false}, 
					],



					axes:{
						xaxis:{
							renderer:$.jqplot.DateAxisRenderer,
							rendererOptions:{tickRenderer:$.jqplot.CanvasAxisTickRenderer},

							pad:1,


							tickOptions:{
								formatString:'%b %#d, %Y', 
							    }


						},
						yaxis:{
							syncTicks:true,
							tickOptions:{formatString:'%.0f'}
						},
					        y2axis:{padMax:2} 
					},

					highlighter:{
						show: true,
						showMarker:true,
						sizeAdjust: 15,
						formatString:'<table class="jqplot_my_highlighter"><tr><td class="title">Date:</td><td class="data">%s</td></tr><tr><td class="title">Value:</td><td class="data">%s</td></tr></table>'

					}
				});
			}


		}
            });


	document.getElementById(chartdiv).innerHTML = "";

}



function showemailaddress() {


	ajaxloader('email_data');

	//document.getElementById(searchmid).innerHTML = "";

	//document.getElementById(cdiv).style.display = 'block'; 

	
	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=showemailaddress",
                dataType: 'html',
                success: function display(data){

			document.getElementById("email_data").innerHTML = data;

		}
            });


}


function changeemailform() {


	ajaxloader('email_edit');

	//document.getElementById(searchmid).innerHTML = "";

	//document.getElementById(cdiv).style.display = 'block'; 

	
	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=changeemailform",
                dataType: 'html',
                success: function display(data){

			document.getElementById("email_edit").innerHTML = data;

		}
            });


}


function dochangeemail() {


	var newemail = document.getElementById("newemail").value;

	ajaxloader('email_edit');


	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=dochangeemail&nea="+newemail,
                dataType: 'html',
                success: function display(data){

			document.getElementById("email_edit").innerHTML = data;

			showemailaddress();

		}
            });

}	


function showgaaccount() {


	ajaxloader('ga_data');


	
	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=showgaaccount",
                dataType: 'html',
                success: function display(data){

			document.getElementById("ga_data").innerHTML = data;

		}
            });


}


function addgaaccount() {


	ajaxloader('ga_edit');


	
	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=addgaaccount",
                dataType: 'html',
                success: function display(data){

			document.getElementById("ga_edit").innerHTML = data;

		}
            });


}


function addgaaccountconfirm() {



	var gaemail = document.getElementById("gaemail").value;
	var gapw = document.getElementById("gapw").value;



	ajaxloader('ga_edit');


	
	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=addgaaccountconfirm&gaemail="+gaemail+"&gapw="+gapw,
                dataType: 'html',
                success: function display(data){

			document.getElementById("ga_edit").innerHTML = data;

			showgaaccount();

		}
            });


}




function editgaaccount() {


	ajaxloader('ga_edit2');


	
	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=editgaaccount",
                dataType: 'html',
                success: function display(data){

			document.getElementById("ga_edit2").innerHTML = data;
			document.getElementById("ga_edit").innerHTML = "";

		}
            });


}



function gaedituser() {

	ajaxloader('ga_edit3');


	
	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=gaedituser",
                dataType: 'html',
                success: function display(data){

			document.getElementById("ga_edit3").innerHTML = data;

		}
            });

}


function gaedituserconfirm() {



	var gaemail = document.getElementById("gaemail").value;
	var gapw = document.getElementById("gapw").value;



	ajaxloader('ga_edit3');


	
	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=gaedituserconfirm&gaemail="+gaemail+"&gapw="+gapw,
                dataType: 'html',
                success: function display(data){

			document.getElementById("ga_edit3").innerHTML = data;

			//document.getElementById("ga_edit2").innerHTML = "";
			showgaaccount();

		}
            });


}



function gatestaccount() {

	ajaxloader('ga_edit3');


	
	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=gatestaccount",
                dataType: 'html',
                success: function display(data){

			document.getElementById("ga_edit3").innerHTML = data;

		}
            });

}

function gatestaccount2() {

	ajaxloader('profile_browser1b');


	
	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=gatestaccount2",
                dataType: 'html',
                success: function display(data){

			document.getElementById("profile_browser1b").innerHTML = data;

		}
            });

}


function gadeleteaccount() {

	ajaxloader('ga_edit3');
	
	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=gadeleteaccount",
                dataType: 'html',
                success: function display(data){

			document.getElementById("ga_edit3").innerHTML = data;

		}
            });

}


function gadeleteaccountconfirm() {

	ajaxloader('ga_edit');
	
	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=gadeleteaccountconfirm",
                dataType: 'html',
                success: function display(data){

			document.getElementById("ga_edit").innerHTML = data;
			document.getElementById("ga_edit2").innerHTML = "";
			document.getElementById("ga_edit3").innerHTML = "";

			showgaaccount();

		}
            });

}


function gaeditprofiles() {

	ajaxloader('profile_browser');
	
	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=gaeditprofiles",
                dataType: 'html',
                success: function display(data){

			document.getElementById("profile_browser").innerHTML = data;


			document.getElementById("ga_edit3").innerHTML = "";

			gashowprofiles();


		}
            });

}
	

function gashowprofiles() {

	ajaxloader('profile_browser3');
	
	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=gashowprofiles",
                dataType: 'html',
                success: function display(data){

			document.getElementById("profile_browser3").innerHTML = data;

		}
            });

}



function gaeditdomainprofile(domainid) {



	ajaxloader('profile_browser2');


	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=gaeditdomainprofile&did="+domainid,
                dataType: 'html',
                success: function display(data){

			document.getElementById("profile_browser2").innerHTML = data;

		}
            });

}	



function changeprofilebutton(domainid) {


	var proid = document.getElementById("profileid").value;


	ajaxloader('profile_browser2');
	

	    $.ajax({
                url: "/myaccount/ga_ajax_actions.php",
                method: 'GET',
		data: "action=gachangedomainprofile&did="+domainid+"&proid="+proid,
                dataType: 'html',
                success: function display(data){

			document.getElementById("profile_browser2").innerHTML = data;

			gashowprofiles();

		}
            });

}




