// JavaScript Document

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}

function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}

function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}





function SetCookie(cookieName,cookieValue,nDays) {

 var today = new Date();

 var expire = new Date();

 if (nDays==null || nDays==0) nDays=1;

 expire.setTime(today.getTime() + 3600000*24*nDays);

 document.cookie = cookieName+"="+escape(cookieValue)

                 + ";expires="+expire.toGMTString();

}



var addKeyword = function(){
	new Ajax.Updater('panel','includes/configpanel.php', {method:'post', postBody:'keyword='+$('keyword').value+'&process=true&keywordsubmit=true'});	
}


var addDomain = function(){
	new Ajax.Updater('panel','includes/configpanel.php', {method:'post', postBody:'domain='+$('domain').value+'&process=true&domainsubmit=true'});	
}

var loadProfile = function(domain){
	new Ajax.Updater('profileholder','includes/account/domainprofile.php', {method:'post', postBody:'domain='+domain});	
}

var addProfile = function(domain){
	new Ajax.Updater('profileholder','includes/account/domainprofile.php', {method:'post', postBody:'domain='+$('profiledomain').value});	
}

function popupWindow(url, width, height) {

				properties = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=' + width + ',height=' + height + ',screenX=150,screenY=150,top=150,left=150'

				

				window.open(url,'popupWindow', properties);

			}




function changeDomain(obj){
	
	var site = $(obj).innerHTML;
	new Ajax.Updater('grader', '/includes/ajaxcontent/websitegrader.php', {asynchronous:true, evalScripts:true, method:'post',postBody:'domain='+site});	


}

function getData(obj){
	
	//alert("gets this far");
	
	$('grader').innerHTML = "<center><br><br> Loading Page Analysis... <br><br><img src='/images/ajax-loader.gif' /></center>";

	var site = $(obj).innerHTML;
	new Ajax.Updater('grader', '/includes/ajaxcontent/dataanalysis.php', {asynchronous:true, evalScripts:true, method:'post',postBody:'page='+site});	


}


function getMap(holder,obj){
	new Ajax.Updater(holder, '/includes/ajaxcontent/sitemap.php', {asynchronous:true, evalScripts:true, method:'post', postBody:'domain='+obj});	


}




function deleteitem(id, url, type, message, attach){

	if(window.confirm(message)){

		location= url+'/'+type+'/'+id+'';

	}

}

function deleteitemAjax(id, url, type, message, attach){

	if(window.confirm(message)){
		if(type == 'delkeyword'){
			new Ajax.Updater('panel', '/includes/configpanel.php?delkeyword='+id+'&process=true', {asynchronous:true, evalScripts:true, method:'get'});
		}
		
		if(type == 'deldomain'){
			new Ajax.Updater('panel', '/includes/configpanel.php?deldomain='+id+'&process=true', {asynchronous:true, evalScripts:true, method:'get'});
		}
	}

}



function refreshData(place){
	//$('loaderback').style.display = "block";
	new Effect.Appear('loaderback');
	/*
	new Ajax.Updater('crap','/includes/graphxml/source/makecharts.php', {method:'post',asynchronous:true,onComplete:function(){
		$('loaderback').style.display = "none";	
		window.location = place;
	}});	
	*/
	
}

var loadTool = function(tool){
	new Effect.Appear('loaderback');
	new Ajax.Updater('reportholder',tool, {method:'get',asynchronous:true});
	$('loaderback').style.zIndex='100';
}

var reportingInit = function(){
	new Effect.Appear('loaderback');
	new Ajax.Updater('reportholder','/includes/ajaxcontent/reportholder.php', {method:'post',asynchronous:true});
}

var loadPage = function(page){
	new Ajax.Updater('controlbody',page, {method:'post',asynchronous:true, postBody:'process=true'});
}


function changeProfile(domain,type){
	new Ajax.Updater('profileinfo', '/includes/domaininfo.php', {asynchronous:true, evalScripts:true, method:'post',postBody:'website='+domain+'&type='+type});	
	//location = "/";
}

function mouseOver(obj){
	$(obj).className='buttonover';
 }
 
 function mouseOut(obj){
	 $(obj).className='buttonout';
 }



function toggleLead(id){
	if($('row'+id).style.display == 'none') {
		$('row'+id).style.display = 'block';

	} else {
		$('row'+id).style.display = 'none';
	}
	
}


function toggleView(id){
	if($('path'+id).style.display == 'none') {
		$('path'+id).style.display = 'block';	
	} else {
		$('path'+id).style.display = 'none';

	}
	
}

function toggleBlock(varid){
	if($(varid).style.display == 'none') {
		$(varid).style.display = 'block';	
	} else {
		$(varid).style.display = 'none';

	}
	
}

function toggleDates(){
	if($('date').checked == true) {
		$('dates').style.display = 'block';	
	} else {
		$('dates').style.display = 'none';

	}
	
}

function getKeywords(keyword){
	$('suggestions').innerHTML = "<center><br><br> Loading Keywoord Suggestions... <br><br><img src='/images/ajax-loader.gif' /></center>";
	
	keyword = $(keyword).value;
	new Ajax.Updater('suggestions', '/includes/keywords/keywordsuggestiontool.php', {asynchronous:true, evalScripts:true, method:'post',postBody:'keyword='+keyword});	
	//location = "/";
}

function updateLinks(sitediv, starting,site){
	$('site'+sitediv).innerHTML = "<center><br><br> Loading Inbound Links... <br><br><img src='/images/ajax-loader.gif' /></center>";

	new Ajax.Updater('site'+sitediv, '/includes/ajaxcontent/fetchinboundlinks.php', {asynchronous:true, evalScripts:true, method:'post',postBody:'starting='+starting+'&domain='+site});	
	//location = "/";
}


function showEdit(){
	if($('editprofile').style.display == 'none'){
		$('editprofile').style.display = 'block';
		$('showprofile').style.display = 'none';
	}else{
		$('editprofile').style.display = 'none';
		$('showprofile').style.display = 'block';
	}
	
}

