function saveBookmarks(arr) {
	var resp = function(req) {
		//alert(req.responseText);
	}

	//var url = '/order/admin/companies_front/saveBookmarks'; // this can't work without mod_rewrite
	var url = 'customer_saveBookmarks.php';
	var pars = 'bookmarks='+arr;	
	var myAjax = new Ajax.Request(url,{ method: 'post',parameters: pars,onComplete:resp});
}

function loginPopup() 
{
window.open('login_popup.php','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=400,screenX=150,screenY=150,top=150,left=150')
}

function InfoMail( address ) 
	{
        domain="vergesport.com"; 
        address + "@" + domain;      
	document.write(
  	'<A HREF="mailto:' + address+'@'+domain + '">' 
  	+ address+'@'+domain + '</a>');	         
	}


					        function verify(form)
					        {
					           var passed = false;
					        var blnRetval, intAtSign, intDot, intComma, intSpace, intLastDot, intDomain, intStrLen;
					        if (form.Email){
					                       intAtSign=form.Email.value.indexOf("@");
					                        intDot=form.Email.value.indexOf(".",intAtSign);
					                        intComma=form.Email.value.indexOf(",");
					                        intSpace=form.Email.value.indexOf(" ");
					                        intLastDot=form.Email.value.lastIndexOf(".");
					                        intDomain=intDot-intAtSign;
					                        intStrLen=form.Email.value.length;
					                // *** CHECK FOR BLANK EMAIL VALUE
					                   if (form.Email.value == "" )
					                   {
					                alert("Please enter e-mail.");
					                form.Email.focus();
					                passed = false;
					                }
					                // **** CHECK FOR THE  @ SIGN?
					                else if (intAtSign == -1)
					                {
					
					                alert("Please enter valid e-mail : \"@\".");
					                        form.Email.focus();
					                passed = false;
					
					                }
					                // **** Check for commas ****
					
					                else if (intComma != -1)
					                {
					                alert("Please enter valid data...");
					                form.Email.focus();
					                passed = false;
					                }
					
					                // **** Check for a space ****
					
					                else if (intSpace != -1)
					                {
					                alert("Please enter valid data");
					                form.Email.focus();
					                passed = false;
					                }
					
					                // **** Check for char between the @ and dot, chars between dots, and at least 1 char after the last dot ****
					
					                else if ((intDot <= 2) || (intDomain <= 1)  || (intStrLen-(intLastDot+1) < 2))
					                {
					                alert("Please check this .\n" + form.Email.value + " is invalid.");
					                form.Email.focus();
					                passed = false;
					                }  else {
					                 passed = true;
					                }
					        	} else    {
					              passed = true;
					        }  return passed;
					  }










function checkBox(object) {
  document.account_newsletter.elements[object].checked = !document.account_newsletter.elements[object].checked;
}

function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}




function materials_popup(type,szer,wys) {
 window.open('materials_popup.php?type='+type,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width='+szer+',height='+wys+',top=300,left=600')

}

function store_materials_popup(type,szer,wys) {
 window.open('../materials_popup.php?type='+type,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width='+szer+',height='+wys+',top=300,left=600')

}


function back_popup(type,szer,wys) 
{
var szer=parseInt(szer)+50;
var szer=parseInt(szer)+30;
  window.open('back_popup.php?type='+type,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=yes,width='+szer+',height='+wys+',top=200,left=400')
}


function check_form_optional(form_name) 
  {
  var form = form_name;

  var firstname = form.elements['firstname'].value;
  var lastname = form.elements['lastname'].value;
  var street_address = form.elements['street_address'].value;

  if (firstname == '' && lastname == '' && street_address == '') {
    return true;
  } else {
    return check_form(form_name);
  }
}



function contact_formvalidation(thisform)
{
with (thisform)
{
if (emptyvalidation(name,"All required fields must be filled in : Name ")==false) {name.focus(); return false;};
if (emptyvalidation(email,"All required fields must be filled in : E-mail Address")==false) {email.focus(); return false;};
if (emailvalidation(email,"You did not enter a valid email address.")==false) {email.focus(); return false;};
if (emptyvalidation(phone,"All required fields must be filled in : Phone")==false) {phone.focus(); return false;};

//if (digitvalidation(phone,1,9,"Please validate quote requests for valid phone numbers—at least 9 numerals","I")==false) {phone.focus(); return false;};

//if (valuevalidation(Value,0,5,"Value MUST be in the range 0-5")==false) {Value.focus(); return false;};
//if (digitvalidation(Digits,3,4,"You MUST enter 3 or 4 integer digits","I")==false) {Digits.focus(); return false;};
}
}




function walidacja_tell_friend(thisform)
{
with (thisform)
{
if (emptyvalidation(to_name,"All required fields must be filled in : Your Friends Name ")==false) {to_name.focus(); return false;};
if (emptyvalidation(to_email_address,"All required fields must be filled in : Your Friends E-Mail ")==false) {to_email_address.focus(); return false;};
if (emailvalidation(to_email_address,"You did not enter a valid email address : Your Friends E-Mail")==false) {to_email_address.focus(); return false;};


if (emptyvalidation(from_name,"All required fields must be filled in : Your Name ")==false) {from_name.focus(); return false;};
if (emptyvalidation(from_email_address,"All required fields must be filled in : Your E-Mail Address ")==false) {from_email_address.focus(); return false;};
if (emailvalidation(from_email_address,"You did not enter a valid email address : Your E-Mail Address")==false) {from_email_address.focus(); return false;};




}
}


function ftp_formvalidation(thisform)
{
with (thisform)
{
if (emptyvalidation(name,"All required fields must be filled in : Name ")==false) {name.focus(); return false;};
if (emptyvalidation(email,"All required fields must be filled in : E-mail Address")==false) {email.focus(); return false;};
if (emailvalidation(email,"You did not enter a valid email address.")==false) {email.focus(); return false;};
if (emptyvalidation(phone,"All required fields must be filled in : Phone")==false) {phone.focus(); return false;};
if (emptyvalidation(grafika,"All required fields must be filled in : Image")==false) {grafika.focus(); return false;};

}
}


function quote_request_formvalidation(thisform)
{
with (thisform)
{
if (emptyvalidation(txtName,"All required fields must be filled in : Name ")==false) {txtName.focus(); return false;};
if (emptyvalidation(txtEmail,"All required fields must be filled in : E-mail Address")==false) {txtEmail.focus(); return false;};
if (emailvalidation(txtEmail,"You did not enter a valid email address.")==false) {txtEmail.focus(); return false;};
if (emptyvalidation(txtPhone,"All required fields must be filled in : Phone")==false) {txtPhone.focus(); return false;};
//if (valuevalidation(Value,0,5,"Value MUST be in the range 0-5")==false) {Value.focus(); return false;};
//if (digitvalidation(txtPhone,1,9,"Please validate quote requests for valid phone numbers—at least 9 numerals","I")==false) {txtPhone.focus(); return false;};
}
}


function emptyvalidation(entered, alertbox)
{

with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function digitvalidation(entered, min, max, alertbox, datatype)
{

with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") 
{checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
}
if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
} 


function valuevalidation(entered, min, max, alertbox, datatype)
{

with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
}
if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
} 


function emailvalidation(entered, alertbox)
{
with (entered)
{
apos=value.indexOf("@"); 
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
} 