// Main js functions for anotherfriend.com
// Copyright (C) 2007 simpo

var scrolT = 0;
var windowH = 0; 
var mouseX = 0;
var mouseY = 0;

var IE = false;
if (navigator.appName == "Microsoft Internet Explorer"){
	IE = true;
	windowH = document.documentElement.clientHeight;
} else {
	windowH = window.innerHeight;
}

if (!IE){
	document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = getMouseXY;


function getMouseXY(m)
{
	if (IE)
	{
		var tmpX = event.clientX;
		var tmpY = event.clientY;
	} else {
		var tmpX = m.pageX;
		var tmpY = m.pageY;     
	}

	if(IE){
	 scrolT = document.documentElement.scrollTop;
	} else {
	 scrolT = document.body.scrollTop; 
	}

	  mouseX = tmpX ;
	  mouseY = tmpY ;
 }

function attachPhotoTooltip(id, pic_id, status)
{
	document.getElementById(id).onmouseover = function()
	{
		mover1(id, pic_id, status);
	};
	
	document.getElementById(id).onmousemove = function()
	{
		mmove1();
	};
	
	document.getElementById(id).onmouseout = function()
	{
		mout1(id);
	};
	
	mover1(id, pic_id, status);
	mmove1();
}

	function mover1(id,pic_id, status)
	{
		
		//document.getElementById(id).style.color = '#FF5000';
		document.getElementById('lay1').style.left = String(mouseX + 15)+"px";
		document.getElementById('lay1').style.top =  String(mouseY + 15)+"px"; 
		//document.getElementById('Lphoto1').src = "images/";
		document.getElementById('Lphoto1').src = pic_id;
		document.getElementById('lay1_status').innerHTML = status;
		document.getElementById('lay1').style.visibility = 'visible'; 
	}
	
	function mmove1()
	{
		if(IE )
			mouseY = mouseY  + scrolT; 
		if(windowH < (mouseY + 185))
			mouseY = mouseY - 185;
		document.getElementById('lay1').style.left = String(mouseX + 15)+"px"; 
		document.getElementById('lay1').style.top = String(mouseY + 15)+"px";
		
	}

	function mout1(id)
	{
		
		//document.getElementById('Lphoto1').src = "";
		document.getElementById('Lphoto1').src ="/images/loader.gif";
		//document.getElementById(id).style.color = '#606060';
		document.getElementById("lay1").style.visibility = 'hidden'; 
   }
   
   
function attachTooltip(id, message)
{
	document.getElementById(id).onmouseover = function()
	{
		tooltip_mover1(id, message);
	};
	
	document.getElementById(id).onmousemove = function()
	{
		tooltip_mmove1();
	};
	
	document.getElementById(id).onmouseout = function()
	{
		tooltip_mout1(id);
	};
	
	tooltip_mover1(id, message);
	tooltip_mmove1();
}

	function tooltip_mover1(id, message)
	{
		
		//document.getElementById(id).style.color = '#FF5000';
		document.getElementById('lay2').style.left = String(mouseX + 15)+"px";
		document.getElementById('lay2').style.top =  String(mouseY + 15)+"px"; 
		//document.getElementById('Lphoto1').src = "images/";

		document.getElementById('lay2').innerHTML = message;
		document.getElementById('lay2').style.visibility = 'visible'; 
	}
	
	function tooltip_mmove1()
	{
		if(IE )
			mouseY = mouseY  + scrolT; 
		if(windowH < (mouseY + 185))
			mouseY = mouseY;
		document.getElementById('lay2').style.left = String(mouseX + 15)+"px"; 
		document.getElementById('lay2').style.top = String(mouseY + 15)+"px";
		
	}

	function tooltip_mout1(id)
	{
		
		//document.getElementById('Lphoto1').src = "";
		//document.getElementById(id).style.color = '#606060';
		document.getElementById("lay2").style.visibility = 'hidden'; 
   }
   
  function display_info(text,header){
	header = typeof(header) != 'undefined' ? header : 'Information';
	var resp;
	//resp = "<center><h1 style='font-size:14px; margin:10px;'>Information</h1></center><div id='' style='width:100%; height:100px; float:left;'></div><div id=''><center>"+text;
	//resp=resp + '</center><br><br><center><a href="##" onClick="Effect.toggle(\'Layer1\');"><img src="/images/closelabel.gif" title="close" border="0"></a></center></div>';
	resp = '<div id="" style="width: 310px;" class="center_right_box"><div style="width: 310px;" class="center_box_right_top"><center><span>'+header+'</span></center></div><div style="padding: 5px; overflow: hidden; width: 300px;" class="center_box_right_middle">'+text+'<div onclick="" style="width: 100px; margin-top: 40px; margin-left: 100px; cursor: pointer;" id="" class="button_box"><div class="button_box_left"></div><div style="width: 90px;" class="button_box_right">';
	resp = resp+'<input type="button" style="padding-right: 8px;" class="rectbutton_input" onClick="Effect.toggle(\'Layer1\');" value="CLOSE" name="op_submit"/></div></div></div></div></div>';
	/*if(IE )
		mouseY = mouseY  + scrolT; 
	if(windowH < (mouseY + 185))
		mouseY = mouseY - 185;
	$('Layer1').style.top = String(mouseY + 15)+"px"; */
	$('Layer3').innerHTML=resp;
	Effect.toggle('Layer1');  
	var mydrag = new Draggable('Layer1', {revert:true})
	}

	function FD_notification(){
		var resp;
		var not;
		resp = "<div id='not_env2'><table cellpadding='0' cellspacing='0' width='100%'><tr height='70' style=''><td><img src='/images/FD_notification_logo.jpg' alt='' /></td></tr><tr><td class='notificator_text'>";
		resp=resp + 'You have been invited for a Frist Date.<br /> Close this message and check the control panel on the left menu &amp; click on the \'ACCEPT\' or \'DECLINE\' button<br /><br /><a href="##" onClick="Effect.toggle(\'Layer1\');Effect.toggle(\'Layer1a\'); "><img src="/images/close_notif.jpg" style="border:0px; margin-top:20px;" title="close"></a></td></tr></table></div>';
		$('Layer3').innerHTML=resp;
		 
		Effect.toggle('Layer1');  
		Effect.toggle('Layer1a');
		
	}
	
	
    // INCLUDE FROM OMNI DATE DEVELOPERS TEAM
	var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
	
	// Hook for Internet Explorer
	if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 &&
	navigator.userAgent.indexOf("Windows") != -1 &&
	navigator.userAgent.indexOf("Windows 3.1") == -1) 
	{
		document.write('<SCRI'+'PT LANGUAGE=VBScript> \n');
		document.write('on error resume next \n');
		document.write('Sub Banner_FSCommand(ByVal command, ByVal args)\n');
		document.write('  call Banner_DoFSCommand(command, args)\n');
		document.write('end sub\n');
		document.write('</SCRI'+'PT> \n');
	}
	
	function Banner_DoFSCommand(command, args)
	{
		//FD_notification();
	}
	
	
	
/********************************************* deactivation window ***************************/

	function deactivateAccount()
	{
		Effect.toggle('Layerdeactivation1');  
		Effect.toggle('Layerdeactivation1a');
	}
	
	function deactivateAccount_step2()
	{
		for(i=0; i<7; i=i+1)
		{
			if(document.deactivationForm.deactivation[i].checked)
			{
				var formValue = i+1;
			}
		}
		if(formValue > 0 && formValue < 8)
		{
			$('validationDeactivationResult').innerHTML = "";
			Effect.Fade("Layerdeactivation3", {duration:0.5});
			window.setTimeout('Effect.Appear("Layerdeactivation4", {duration:0.5})', 550);	
		}
		else
		{
			$('validationDeactivationResult').innerHTML = "<span style='color:red; font-size:8pt; font-weight:bold;'>* Please select one of options</span>";
			return false;
		}
	}
	
	function deactivateAccount_step3()
	{
		Effect.Fade("Layerdeactivation4", {duration:0.5});
		window.setTimeout('Effect.Appear("Layerdeactivation5", {duration:0.5})', 550);
		var resp;
		resp = "<img src='images/deactivating_top3.jpg' alt='deactivatiob top image' />";
		resp=resp + '<div style="width:487px; height:100%; padding:30px 10px 40px 10px; background-color:#EBEEFD; border-left:1px solid #707175; border-right:1px solid #707175; border-bottom:1px solid #707175;">';
		resp=resp + '<div style="width:420px; margin:auto; color:#6B7CA7; font-size:11px;"><span style="font-weight:bold; color:#5B6C9A; font-size:11px;">Your Membership of AnotherFriend.com will be deactivated.</span><br /><br />Thank you for your membership & we hope you enjoyed the site.<br /><br />Happy Dating.</div>';
		resp=resp + '<div style="width:420px; margin:auto; margin-top:60px;"><a href="" onClick="Effect.toggle(\'Layerdeactivation1\');Effect.toggle(\'Layerdeactivation1a\');"><img src="/images/ok_button.gif" style="border:0px; margin-top:90px;" title="ok"></a></div>';
		$('Layerdeactivation5').innerHTML=resp;
	}
	
	function deactivateAccount_step4()
	{
		Effect.Fade("Layerdeactivation4", {duration:0.5});
		window.setTimeout('Effect.Appear("Layerdeactivation5", {duration:0.5})', 550);
		var resp;
		resp = "<img src='images/deactivating_top3.jpg' alt='deactivatiob top image' />";
		resp=resp + '<div style="width:487px; height:100%; padding:30px 10px 40px 10px; background-color:#EBEEFD; border-left:1px solid #707175; border-right:1px solid #707175; border-bottom:1px solid #707175;">';
		resp=resp + '<div style="width:420px; margin:auto; color:#6B7CA7; font-size:11px;"><span style="font-weight:bold; color:#5B6C9A; font-size:11px;">Your Membership of AnotherFriend.com will be deactivated.</span><br /><br />All your subscription will be cancelled within 72 hours.<br /><br />Thank you for your membership & we hope you enjoyed the site.<br /><br />Happy Dating.</div>';
		resp=resp + '<div style="width:420px; margin:auto; margin-top:60px;"><a href="" onClick="Effect.toggle(\'Layerdeactivation1\');Effect.toggle(\'Layerdeactivation1a\');"><img src="/images/ok_button.gif" style="border:0px; margin-top:90px;" title="ok"></a></div>';
		$('Layerdeactivation5').innerHTML=resp;
	}
	
	function sendDeactivateData(id)
	{	
		for(i=0; i<10; i=i+1)
		{
			if(document.deactivationForm2.deactivation2[i].checked)
			{
				var formValue2 = i+1;
			}
		}
		for(i=0; i<7; i=i+1)
		{
			if(document.deactivationForm.deactivation[i].checked)
			{
				var formValue = i+1;
			}
		}
		var df3 = document.deactivationForm.deactivationTextarea.value;
		
		if(formValue2 > 0 && formValue2 < 11)
		{
			$('validationDeactivationResult2').innerHTML = "";
			var opt = {
			method: 'post',
			postBody: "df1="+formValue+"&df2="+formValue2+"&c="+id+"&df3="+encodeURIComponent(df3),
			onSuccess: function(transport){
			if(id == 0)
			{
				deactivateAccount_step3();
			}
			else
			{
				deactivateAccount_step4();
			}
			},
			
			on404: function(transport) {
				alert('Error 404: location "' + transport.statusText + '" was not found.');
			},
			onFailure: function(transport) {
				alert('Error ' + transport.status + ' -- ' + transport.statusText);
			}				
			}
			new Ajax.Request('/ajax/foo.cfm?ac_id=52', opt);
			return 0;
		}
		else
		{
			$('validationDeactivationResult2').innerHTML = "<span style='color:red; font-size:8pt; font-weight:bold;'>* Please select one of options</span>";
			return false;
		}	
	}