function refreshParent() {

  window.opener.location.href = window.opener.location.href;

 

  if (window.opener.progressWindow)

              

 {

    window.opener.progressWindow.close()

  }

  window.close();

}




function refresher() {

  window.opener.location.href = window.opener.location.href ;

 

}





var windowW=600 // wide
var windowH=425 // high
// set the screen position where the popup should appear
var windowX = 10 // from left
var windowY = 10 // from top
// set the url of the page to show in the popup
// set the title of the page
var title =  "Pink Pebbles"
// set this to true if the popup should close
// upon leaving the launching page; else, false
var autoclose = true
// ============================
// do not edit below this line
// ============================
s = "width="+windowW+",height="+windowH;
var beIE = document.all?true:false
function updateOrder(urlPop){

  if (beIE){
    NFW = window.open("","popFrameless","fullscreen,"+s)     
    NFW.blur()
    window.focus()       
    NFW.resizeTo(windowW,windowH)
    NFW.moveTo(windowX,windowY)
    var frameString=""+
"<html>"+
"<head>"+
"<title>"+title+"</title>"+
"</head>"+
"<frameset rows='*,0' framespacing=0 border=0 frameborder=0>"+
"<frame name='top' src='"+urlPop+"' scrolling=auto>"+
"<frame name='bottom' src='about:blank' scrolling='no'>"+
"</frameset>"+
"</html>"
    NFW.document.open();
    NFW.document.write(frameString)
    NFW.document.close()
  } else {
    NFW=window.open(urlPop,"popFrameless","scrollbars,"+s)
    NFW.blur()
    window.focus() 
    NFW.resizeTo(windowW,windowH)
    NFW.moveTo(windowX,windowY)
  }   
  NFW.focus()   
  if (autoclose){
    window.onunload = function(){NFW.close()}
  }
}






/////////////////////////////////////////////////////////////////////////// User Name Check Insert user ////////////

var xmlhttp

function userName(str)
{
	    //var str =    document.forms.insertUser.user_name.value;
	
	
	
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="http://www.pinkpebblesshop.com/userAJAX.php?cmd=testUser";
url=url+"&user_name="+str;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("userError").innerHTML=xmlhttp.responseText;

  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

/////////////////////////////////////////////////////////////////////////// User Name check Edit User ////////////

var xmlhttp

function userNameEditUser(str)
{
	    //var str =    document.forms.insertUser.user_name.value;
	
	
	
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="http://www.pinkpebblesshop.com/userAJAX.php?cmd=testUser";
url=url+"&user_name="+str;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("userError").innerHTML=xmlhttp.responseText;

  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}


/////////////////////////////////////////////////////////////////user email insert user page //////////////////////////////
var xmlhttp


function userEmail()
{
	    var str2 =    document.forms.insertUser.email.value;
	
	
	
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url2="http://www.pinkpebblesshop.com/emailAJAX.php?cmd=testEmail";
url2=url2+"&email="+str2;
xmlhttp.onreadystatechange=stateChanged2;
xmlhttp.open("GET",url2,true);
xmlhttp.send(null);
}

function stateChanged2()
{
if (xmlhttp.readyState==4)
  {
	 
  document.getElementById("emailError").innerHTML=xmlhttp.responseText;

  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

/////////////////////////////////////////////////////////////////user email EDIT user page //////////////////////////////
var xmlhttp


function userEmailEdit()
{
	    var str2 =    document.forms.editUser.email.value;
	
	
	
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url2="http://www.pinkpebblesshop.com/emailAJAX.php?cmd=testEmail";
url2=url2+"&email="+str2;
xmlhttp.onreadystatechange=stateChanged2;
xmlhttp.open("GET",url2,true);
xmlhttp.send(null);
}

function stateChanged2()
{
if (xmlhttp.readyState==4)
  {
	 
  document.getElementById("emailError").innerHTML=xmlhttp.responseText;

  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}


///////////////////////////////////////////////////////////////////////////////Validate EMAIL///////////////////////////////////////////////////////////////

function verifyEmail(form) {
checkEmail = document.insertUser.email.value;

if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.')))

if (document.insertUser.email.value == '') 
{ }

else {
{alert("You have entered an invalid email address. Please try again.");
document.insertUser.email.value = '';
document.insertUser.email.focus();
return false;
}

}
}

function verifyEmailEdit(form) {
checkEmail = document.editUser.email.value;

if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.')))

if (document.editUser.email.value == '') { } else {
{alert("You have entered an invalid email address. Please try again.");
document.editUser.email.value = '';
document.editUser.email.focus();
return false;
}
}

}

function verifyEmailOrder(form) {
	
checkEmail = document.getElementById('ship_email').value;


if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.')))

if (document.placeOrder.ship_email.value == '') { } else {

{alert("You have entered an invalid email address. Please try again.");
document.placeOrder.ship_email.value = '';
document.placeOrder.ship_email.focus();
return false;
}
}

}

function contactForm(form) {
	
checkEmail = document.contact.email.value;

if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.')))

if (document.contact.email.value == '') { } else {

{alert("You have entered an invalid email address. Please try again.");
document.contact.email.value = '';
document.contact.email.focus();
return false;
}
}

}



////////////////////////////////////////////////////PHONE VALIDATION place order ////////////////////////////////////////////////////////////////////

var n;
var p;
var p1;
function ValidatePhone(){
p=p1.value
if(p.length==3){
	//d10=p.indexOf('(')
	pp=p;
	d4=p.indexOf('(')
	d5=p.indexOf(')')
	if(d4==-1){
		pp="("+pp;
	}
	if(d5==-1){
		pp=pp+")";
	}
	//pp="("+pp+")";
	document.placeOrder.ship_phone.value="";
	document.placeOrder.ship_phone.value=pp;
}
if(p.length>3){
	d1=p.indexOf('(')
	d2=p.indexOf(')')
	if (d2==-1){
		l30=p.length;
		p30=p.substring(0,4);
		//alert(p30);
		p30=p30+")"
		p31=p.substring(4,l30);
		pp=p30+p31;
		//alert(p31);
		document.placeOrder.ship_phone.value="";
		document.placeOrder.ship_phone.value=pp;
	}
	}
if(p.length>5){
	p11=p.substring(d1+1,d2);
	if(p11.length>3){
	p12=p11;
	l12=p12.length;
	l15=p.length
	//l12=l12-3
	p13=p11.substring(0,3);
	p14=p11.substring(3,l12);
	p15=p.substring(d2+1,l15);
	document.placeOrder.ship_phone.value="";
	pp="("+p13+")"+p14+p15;
	document.placeOrder.ship_phone.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
	l16=p.length;
	p16=p.substring(d2+1,l16);
	l17=p16.length;
	if(l17>3&&p16.indexOf('-')==-1){
		p17=p.substring(d2+1,d2+4);
		p18=p.substring(d2+4,l16);
		p19=p.substring(0,d2+1);
		//alert(p19);
	pp=p19+p17+"-"+p18;
	document.placeOrder.ship_phone.value="";
	document.placeOrder.ship_phone.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
}
//}
setTimeout(ValidatePhone,100)
}
function getIt(m){
n=m.name;
//p1=document.forms[0].elements[n]
p1=m
ValidatePhone()
}
function testphone(obj1){
p=obj1.value
//alert(p)
p=p.replace("(","")
p=p.replace(")","")
p=p.replace("-","")
p=p.replace("-","")
//alert(isNaN(p))
if (isNaN(p)==true){
alert("Check phone");
return false;
}
}

////////////////////////phone validation  new user

var n;
var p;
var p1;
function ValidatePhoneNewUser(){
p=p1.value
if(p.length==3){
	//d10=p.indexOf('(')
	pp=p;
	d4=p.indexOf('(')
	d5=p.indexOf(')')
	if(d4==-1){
		pp="("+pp;
	}
	if(d5==-1){
		pp=pp+")";
	}
	//pp="("+pp+")";
	document.insertUser.phone.value="";
	document.insertUser.phone.value=pp;
}
if(p.length>3){
	d1=p.indexOf('(')
	d2=p.indexOf(')')
	if (d2==-1){
		l30=p.length;
		p30=p.substring(0,4);
		//alert(p30);
		p30=p30+")"
		p31=p.substring(4,l30);
		pp=p30+p31;
		//alert(p31);
		document.insertUser.phone.value="";
		document.insertUser.phone.value=pp;
	}
	}
if(p.length>5){
	p11=p.substring(d1+1,d2);
	if(p11.length>3){
	p12=p11;
	l12=p12.length;
	l15=p.length
	//l12=l12-3
	p13=p11.substring(0,3);
	p14=p11.substring(3,l12);
	p15=p.substring(d2+1,l15);
	document.insertUser.phone.value="";
	pp="("+p13+")"+p14+p15;
	document.insertUser.phone.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
	l16=p.length;
	p16=p.substring(d2+1,l16);
	l17=p16.length;
	if(l17>3&&p16.indexOf('-')==-1){
		p17=p.substring(d2+1,d2+4);
		p18=p.substring(d2+4,l16);
		p19=p.substring(0,d2+1);
		//alert(p19);
	pp=p19+p17+"-"+p18;
	document.insertUser.phone.value="";
	document.insertUser.phone.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
}
//}
setTimeout(ValidatePhoneNewUser,100)
}
function getItNewUser(m){
n=m.name;
//p1=document.forms[0].elements[n]
p1=m
ValidatePhoneNewUser()
}
function testphone(obj1){
p=obj1.value
//alert(p)
p=p.replace("(","")
p=p.replace(")","")
p=p.replace("-","")
p=p.replace("-","")
//alert(isNaN(p))
if (isNaN(p)==true){
alert("Check phone");
return false;
}
}

//////////////////////////////////////////////////phone validation for edit user

////////////////////////phone validation  new user

var n;
var p;
var p1;
function ValidatePhoneEditUser(){
p=p1.value
if(p.length==3){
	//d10=p.indexOf('(')
	pp=p;
	d4=p.indexOf('(')
	d5=p.indexOf(')')
	if(d4==-1){
		pp="("+pp;
	}
	if(d5==-1){
		pp=pp+")";
	}
	//pp="("+pp+")";
	document.editUser.phone.value="";
	document.editUser.phone.value=pp;
}
if(p.length>3){
	d1=p.indexOf('(')
	d2=p.indexOf(')')
	if (d2==-1){
		l30=p.length;
		p30=p.substring(0,4);
		//alert(p30);
		p30=p30+")"
		p31=p.substring(4,l30);
		pp=p30+p31;
		//alert(p31);
		document.editUser.phone.value="";
		document.editUser.phone.value=pp;
	}
	}
if(p.length>5){
	p11=p.substring(d1+1,d2);
	if(p11.length>3){
	p12=p11;
	l12=p12.length;
	l15=p.length
	//l12=l12-3
	p13=p11.substring(0,3);
	p14=p11.substring(3,l12);
	p15=p.substring(d2+1,l15);
	document.editUser.phone.value="";
	pp="("+p13+")"+p14+p15;
	document.editUser.phone.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
	l16=p.length;
	p16=p.substring(d2+1,l16);
	l17=p16.length;
	if(l17>3&&p16.indexOf('-')==-1){
		p17=p.substring(d2+1,d2+4);
		p18=p.substring(d2+4,l16);
		p19=p.substring(0,d2+1);
		//alert(p19);
	pp=p19+p17+"-"+p18;
	document.editUser.phone.value="";
	document.editUser.phone.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
}
//}
setTimeout(ValidatePhoneEditUser,100)
}
function getItEditUser(m){
n=m.name;
//p1=document.forms[0].elements[n]
p1=m
ValidatePhoneEditUser()
}
function testphone(obj1){
p=obj1.value
//alert(p)
p=p.replace("(","")
p=p.replace(")","")
p=p.replace("-","")
p=p.replace("-","")
//alert(isNaN(p))
if (isNaN(p)==true){
alert("Check phone");
return false;
}
}


///////////////////////////////////////////////////////////////////

///////////////////////////////////////////////New Item Validation///////////////////////////////////////////

function newItemValid(form) {
 
    if (form.item_type.value.length == "") {
    alert("Please select item type!");
    form.item_type.focus();
    return;
  }
 
  
  if (form.item_name.value.length == 0) {
    alert("Please enter item name!");
    form.item_name.focus();
    return;
  }
 
 if (form.item_price.value.length == "") {
    alert("Please enter item price!");
    form.item_price.focus();
    return;
  }
  
  if (form.quantity.value.length == "") {
    alert("Please enter item amount!!");
    form.quantity.focus();
    return;
  }
  
   if (form.item_sold_by.value.length == 0) {
    alert("Please enter items units sold by!!!");
    form.item_sold_by.focus();
    return;
  }
  
}

//////////////////////////////////////////////// delete/////////////////


function ondeleteclick(yea)
   {
   if (!confirm('Are you sure you want to delete this item?')) {  } 
   else { return false;}; 
   }
 
  

