/*
//////////////////////////////////////////////////////////////////////////////////////////////////////
//	File				: functions.js
##
##	Created By			: Mathlesh Kumar
##
##	Created On			: Novermber 07th, 2005
##
##	Purpose				: This file contains javascript functions which will be used all over the site
/////////////////////////////////////////////////////////////////////////////////////////////////////

/* writes some text into document on certain droplist change */
function checkDroplist()
{	
	if (document.bid.type.value != "Permanent Link")
	{
		document.bid.pay_type.value = "per month";
	}
	else document.bid.pay_type.value = "";
}



/* toggle layers for hiding and unhiding */
function toggleLayer(whichLayer)
{
if (document.getElementById)
{
// this is the way the standards work
var style2 = document.getElementById(whichLayer).style;
}
else if (document.all)
{
// this is the way old msie versions work
var style2 = document.all[whichLayer].style;
}
else if (document.layers)
{
// this is the way nn4 works
var style2 = document.layers[whichLayer].style;
}
	style2.display = style2.display? "":"block";

}

function NewWin(id,x,y) {
	if((x*1 == NaN) || (x == ""))x = 800;
	if((y*1 == NaN) || (y == ""))y = 400;
	window.open("_popup.php?id="+id, "Langas", "resizable=yes,scrollbars=yes,status=no,menubar=yes,titlebar,height="+y+",width="+x+"");
}

function inputDomainFocus (target) { if (target.value == 'your-domain.com') target.value = ''; }
function inputDomainBlur (target) {	if (target.value == '') target.value = 'your-domain.com';	}

function go(loc) { window.location.href = loc; }


function taskConfirmation(thisform)
{
	with (thisform)
{
	conf = confirm("Are you sure you want to save this task with following parameters? Order Name: "+project_name.value+", Assigned To: "+assigned_to.value+", Pay Type: "+pay_type.value+", Price: $"+price.value+", Alert Asignee: "+alert_user.checked+", Alert Client: "+alert_client.checked);
	if(conf)
	{		return true;	}
	else
	{		return false;	}

}
}

function confirmation2(text,url) {
	var answer = confirm(text)
	if (answer){ window.location = url; }

}
function confirmation(thisform)
{
	conf = confirm("Are you sure you want to decline the keyword because due to the following reason?");
	if(conf)
	{ return true;go('index.php?conf');	}
	else
	{ go('index.php?nonconf');	}
}
function droplist(value)
{
	if (value != "index.php?new_group=yes") { go(value); }
	else {enterText("Enter new group name","create website group named","index.php?new_group=","");}

}

function enterText(promptTitle,confirmText,url,defaultText)
{
	var answer = prompt (promptTitle,defaultText)
	if (answer != null)
	{confirmAction(confirmText+"\n\n "+answer,url+answer);}
}


 function confirmAction(actionDescription,url)
			{
            if(window.confirm("Are you sure you want "+actionDescription)){go(""+url+"");}
        	}

function checkemail(email)
{
	var testresults
	var str=email
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
	testresults=true
	else{
	testresults=false
	}
	return (testresults)
}
function confirmation(txt)
{
	conf = confirm(txt);
	if(conf)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function check_new_domain()
	{
		var obj=document.add_domain
		
		if(obj.new_domain.value == "your-domain.com")
		{
			alert("Please enter the domain name")
			obj.new_domain.focus();
			return false;
		}
		return true;
	}

function check_new_client_info()
	{
		var obj=document.step3
		
		
		if(obj.email.value=="")
		{
			alert("Please specify your email address. This will serve as your Rank Pay username in the future")
			obj.email.focus();
			return false;
		}
		if(obj.password.value=="")
		{
			alert("Please enter the password")
			obj.password.focus();
			return false;
		}
		if(obj.confirm_password.value=="")
		{
			alert("Please repeat the password")
			obj.confirm_password.focus();
			return false;
		}
		if(obj.password.value!=obj.confirm_password.value)
		{
			alert("Password and confirm password fields doesn't match")
			obj.confirm_password.focus();
			return false;
		}
		if(obj.cc_name.value=="")
		{
			alert("Please enter your name as it appers on the card")
			obj.cc_name.focus();
			return false;
		}

		if(obj.cc_number.value=="")
		{
			alert("Please enter your credit card number")
			obj.cc_number.focus();
			return false;
		}
		if(obj.cc_cvc.value=="")
		{
			alert("Please enter the CVC code which is located on the back of your card")
			obj.cc_number.focus();
			return false;
		}
		if(obj.terms_accepted.checked== false)
		{
			alert("Please read and accept service terms")
			obj.terms_accepted.focus();
			return false;
		}


		return true;
	}





