var topLocation = top.location.hostname;
if(topLocation=='dresses.glamourgirlmodeling.co.uk')
{
// alert('This is NOT the real site');
 top.location.href='http://www.justdresses.co.uk/blank_index.php';
// alert(topLocation); 

}
else
{
// alert(topLocation); 
//	alert('This is NOT the Real Site')
}

function confirmDelete(id, path){
	var $currentURL = path;
	var okToDelete = confirm('Are you sure you want to delete this record?');

	if(okToDelete){
	$currentURL= "jdadminarea/process/" + $currentURL + "_u.php?act=d&id=" + id;
		location.href = $currentURL;
	}
}


function changeImages() {
			for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}

function OpenWindow($im, $name)
{
$features="";
$features+="width=620, ";
$features+="height=620, ";
$features+="toolbars=no, ";
$features+="resizable=no, ";
$features+="location=no, ";
$features+="directories=no, ";
$features+="status=no, ";
$features+="menubar=no, ";
$features+="scrollbars=no, ";
$features+="left=50, ";
$features+="top=50";

win=window.open($im, $name, $features);
win.focus();

}

function validate_registration(item)
{
	
	var $e_mail;
	var $username;
	var $lastname;
	var $password1;
	var $password2;
	var	$address1;
	var $town;
	var $county;
	var $country;
	var $telephone;
	var $response;
	var $errors;

	$e_mail=item.email.value;
	$username=item.username.value;
	$lastname=item.lastname.value;
	$password1=item.password1.value;
	$password2=item.password2.value;
	$address1=item.address_1.value;
	$town=item.address_t.value;
	$county=item.address_c.value;
	$country=item.address_ctry.value;
	$telephone=item.telephone.value;
	
	$response="There are errors on the form: \n";
	$errors=0;
	
	if (isEmpty($e_mail) )
	{
		$response+="\n- Return e-mail address not entered";
		$errors+=1;
	}

	if (! isEmail($e_mail) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}
		$response+="\n- E-mail address invalid";
		$errors+=1;
	}

	if (isEmpty($username) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- First name not entered";
		$errors+=1;
	}

	if (isEmpty($lastname) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Last name not entered";
		$errors+=1;
	}

	
	
	if (isEmpty($password1) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Password not entered";
		$errors+=1;
	}

	if (isEmpty($password2) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Repeated Password not entered";
		$errors+=1;
	}

	if ($password1.length <6 )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Password to short";
		$errors+=1;
	}

	
	if ($password1!=$password2)
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Password and Repeated Password are not the same";
		$errors+=1;
	}

	if (isEmpty($address1) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- First line of address not entered";
		$errors+=1;
	}

	if (isEmpty($town) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Town not entered";
		$errors+=1;
	}
	
	if (isEmpty($county) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- County not entered";
		$errors+=1;
	}

	if (isEmpty($country) || $country==0 )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Country not entered";
		$errors+=1;
	}

	if (isEmpty($telephone) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Telephone number not entered";
		$errors+=1;
	}
	
	
	
	
	if ($errors==0)
	{
//		alert ("OK");
		return true;
	}
	else
	{
		alert ($response);
		return false;
	}
}

function validate_checkout(item)
{
	var $e_mail;
	var $username;
	var $lastname;
	var	$address1;
	var $del_name;
	var $del_address_1;
	var $del_address_town;
	var $del_address_country;
	var $response;
	var $errors;

	$e_mail=item.email_name.value;
	$username=item.name.value;
	$lastname=item.lastname.value;
	$address1=item.address_1.value;
	$town=item.address_town.value;
	$county=item.address_county.value;
	$country=item.address_country.value;
	$del_name=item.del_name.value;
	$del_address_1=item.del_address_1.value;
	$del_address_town=item.del_address_town.value;
	$del_address_country=item.del_address_country.value;
	

	$response="There are errors on the form: \n";
	$errors=0;

	if (isEmpty($e_mail) )
	{
		$response+="\n- Return e-mail address not entered";
		$errors+=1;
	}

	if (! isEmail($e_mail) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}
		$response+="\n- Return e-mail address invalid";
		$errors+=1;
	}

	if (isEmpty($username) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Account Holder First name not entered";
		$errors+=1;
	}

	if (isEmpty($lastname) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Account Holder Last name not entered";
		$errors+=1;
	}

	if (isEmpty($address1) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Account Holder Address not complete";
		$errors+=1;
	}

	if (isEmpty($town) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Account Holder Town not entered";
		$errors+=1;
	}
	
	if (isEmpty($county) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Account Holder County not entered";
		$errors+=1;
	}

	if (isEmpty($country) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Account Holder Country not entered";
		$errors+=1;
	}

	
	if ($del_name!="" || $del_address_1!="" || $del_address_town!="" || $del_address_country>0)
	{
		
		if(isEmpty($del_name) )
		{
			if ($errors!=0)
			{
				$response+=", ";
			}

			$response+="\n- Delivery Name not entered";
			$errors+=1;
		}
		
		if(isEmpty($del_address_1) )
		{
			if ($errors!=0)
			{
				$response+=", ";
			}

			$response+="\n- Delivery Address not entered";
			$errors+=1;
		}

		
		if(isEmpty($del_address_town) )
		{
			if ($errors!=0)
			{
				$response+=", ";
			}

			$response+="\n- Delivery Town not entered";
			$errors+=1;
		}

		
		if($del_address_country==0 )
		{
			if ($errors!=0)
			{
				$response+=", ";
			}

			$response+="\n- Delivery Country not entered";
			$errors+=1;
		}

		
	}
		
		
	
	
	if ($errors==0)
	{
//		alert ("OK");
		return true;
	}
	else
	{
		alert ($response);
		return false;
	}
}





function validate_password_change(item)
{
	var $password1;
	var $password2;
	var $response;
	var $errors;

	$password1=item.newpassword1.value;
	$password2=item.newpassword2.value;

	$response="There are errors on the form: \n";
	$errors=0;


	if (isEmpty($password1) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Password not entered";
		$errors+=1;
	}

	if (isEmpty($password2) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Repeated Password not entered";
		$errors+=1;
	}

	if ($password1.length <6 )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Password to short";
		$errors+=1;
	}

	
	if ($password1!=$password2)
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Password and Repeated Password are not the same";
		$errors+=1;
	}


	if ($errors==0)
	{
//		alert ("OK");
		return true;
	}
	else
	{
		alert ($response);
		return false;
	}
}



function validate_mail_form(item)
{
	var $e_mail;
	var $title;
	var $message;
	var $response;
	var $errors;

	$e_mail=item.messagefrom.value;
	$title=item.messagetitle.value;
	$message=item.message.value;

	$response="Errors:- ";
	$errors=0;

	if (isEmpty($e_mail) )
	{
		$response+="\nReturn e-mail address not entered";
		$errors+=1;
	}

	if (! isEmail($e_mail) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}
		$response+="\nReturn e-mail address invalid";
		$errors+=1;
	}

	if (isEmpty($title) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\nMessage title not entered";
		$errors+=1;
	}

	if (isEmpty($message) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\nBody of message not entered";
		$errors+=1;
	}

	if ($errors==0)
	{
//		alert ("OK");
		return true;
	}
	else
	{
		alert ($response);
		return false;
	}

}


function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isEmail (s)
{   
   
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)

    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;

    else 

return true;
}


function PopupLand(url)
{
// This function is used to display the images in Landscape in a named window.
// If the window is already open then it will just update the existing contents
//
// Expected to be used in hypertext links, e.g.:
// <A HREF=DisplayItem.asp?ObjID=CIV:1021 onClick="OpenTaskWindow('xyz.htm');return false;\>

//  windowName = "_blank";
  windowName = "PopupLand";
  params  = "";
  params += "toolbar=0,";
  params += "location=0,";
  params += "directories=0,";
  params += "status=0,";
  params += "menubar=1,";
  params += "scrollbars=1,";
  params += "resizable=1,";
  params += "width=700,";
  params += "height=600,";
  params += "left=50,";
  params += "top=75,";

    win = window.open(url, windowName, params);
    win.focus();

}

function PopupPort(url)
{
// This function is used to display the bedroom images in Portrait in a named window.
// If the window is already open then it will just update the existing contents
//
// Expected to be used in hypertext links, e.g.:
// <A HREF=DisplayItem.asp?ObjID=CIV:1021 onClick="OpenTaskWindow('xyz.htm');return false;\>

//  windowName = "_blank";
  windowName = "PopupPort";
  params  = "";
  params += "toolbar=0,";
  params += "location=0,";
  params += "directories=0,";
  params += "status=0,";
  params += "menubar=0,";
  params += "scrollbars=0,";
  params += "resizable=0,";
  params += "width=400,";
  params += "height=400,";
  params += "left=50,";
  params += "top=75,";

    win = window.open(url, windowName, params);
    win.focus();

}

function ChangeMonth(item)
{
document.getElementById('current_month').style.display="none";
document.getElementById('month1').style.display="none";
document.getElementById('month2').style.display="none";
document.getElementById('month0').style.display="none";

document.getElementById(item).style.display="block";
	
	}

function pausecomp(millis){ 
 var date = new Date(); 
 var curDate = null; 
 do { curDate = new Date(); } 
 while(curDate-date < millis); 



} 
	
		
function UpdateOrderSEC()
{
//	alert("get started");

	document.ConfirmPurchase.action = "http://www.ic-business-solutions.co.uk/index.php?inc=10003";
	document.ConfirmPurchase.target = "_secpay";		// 
	document.ConfirmPurchase.submit();			// Submit the page

	document.ConfirmPurchase.action = "process/save_temp_order_sec.php";
	document.ConfirmPurchase.target = "_self";
	document.ConfirmPurchase.submit();			// Submit the page
	
//	alert("Now wait");
	
//	setTimeout( "alert('Now go to SECPay'), 900");
//	setTimeout( "history.go(-1)", 1000);
	setTimeout( "CheckOutSEC()", 1500);

//	pausecomp(5000);
//	alert("Now go to SECPay");
//	CheckOutSEC();
	
}

function CheckOutSEC()
{

	document.ConfirmPurchase.action = "https://www.secpay.com/java-bin/ValCard";
	document.ConfirmPurchase.target = "_self";		// Open is same window
	document.ConfirmPurchase.submit();			// Submit the page
//	return false;
}
	
		
function UpdateOrderPP()
{
	document.ConfirmPurchase.action = "process/save_temp_order.php";
	document.ConfirmPurchase.target = "_self";
	document.ConfirmPurchase.submit();			// Submit the page
	
//	alert("Your Order will now be saved on our systems");
//	setTimeout(history.go(), 1000);
//	setTimeout("CheckOutPP()", 1000);
	
}

function CheckOutPP()
{
	alert("Order stored, now proceed to PayPal");
	document.ConfirmPurchase.action = "https://www.paypal.com/cgi-bin/webscr method='POST'";
	document.ConfirmPurchase.target = "_self";		// Open is same window
	document.ConfirmPurchase.submit();			// Submit the page
	return false;
}

function CheckOutPPTest()
{
	alert("Stage2");
	
	document.ConfirmPurchase.action = "process/paypal_ipn.php";
	document.ConfirmPurchase.target = "pp";		// Open is same window
	document.ConfirmPurchase.submit();			// Submit the page
	
	document.ConfirmPurchase.action = "pf_index.php?inc=1020"
	document.ConfirmPurchase.target = "Invoice";		
	document.ConfirmPurchase.submit();			// Submit the page

	document.ConfirmPurchase.action = "index.php?inc=0"
	document.ConfirmPurchase.target = "_self";		
	document.ConfirmPurchase.submit();			// Submit the page
	return false
}


function UpdateOrderCheq(item)
{
//	var $id;
//	$id=item.custom.value;
	
//	alert($id);
	
	document.ConfirmPurchase.action = "process/save_perm_order.php"
	document.ConfirmPurchase.target = "_self";
	document.ConfirmPurchase.submit();			// Submit the page
	return false;
	
//	setTimeout("UpdateOrderCheq2()", 1000)
}

function UpdateOrderCheq2()
{
//	alert("part 2");
	
//	document.ConfirmPurchase.action = "pf_index.php?inc=1020&id=" . id;
//	document.ConfirmPurchase.target = "_self";		
//	document.ConfirmPurchase.submit();			// Submit the page

//	document.ConfirmPurchase.action = "index.php?inc=0"
//	document.ConfirmPurchase.target = "_self";		
//	document.ConfirmPurchase.submit();			// Submit the page
	return false;
}


