var win2 = '';
function edit(editpage,part,subpart,height){
	win2=window.open('','','scrollbars');
	win2.location = 'admin.asp?action=edit&editpage='+editpage+'&part='+part+'&subpart='+subpart+'&height='+height;
}
function newitem(editpage,part,subpart,height){
	win2=window.open('','','scrollbars');
	win2.location = 'admin.asp?action=new&editpage='+editpage+'&part='+part+'&subpart='+subpart+'&height='+height;
}
function checknumber(ite){
	chars = "01234566789-. ()+"
	for (i = 0;  i < ite.value.length;  i++) {
			tocheck = ite.value.charAt(i);  
			allow = true
			for (j = 0;j<chars.value.length;j++){
					char = chars.value.charAt(j)
					if (tocheck != char){
						allow = false
					}
			}
			if(!allow){ checknumber= false}
	}
	checknumber = true
}
function CreateBookmarkLink() {

 title = "ABT Systems" ;
  // Blogger - Replace with <$BlogItemTitle$> 
  // MovableType - Replace with <$MTEntryTitle$>

 url = "http://www.abtsystems.ie";
  // Blogger - Replace with <$BlogItemPermalinkURL$> 
  // MovableType - Replace with <$MTEntryPermalink$>
  // WordPress - <?php bloginfo('url'); ?>

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }
function del(editpage,part,subpart,height){
	win2=window.open('','','scrollbars');
	win2.location = 'admin.asp?action=del&editpage='+editpage+'&part='+part+'&subpart='+subpart+'&height='+height;
}
function opencal(){
	win2=window.open('','','scrollbars');
	win2.location = 'cal.asp';
}
function login(){
	win2=window.open('','','scrollbars');
	win2.location = 'admin.asp';
}
function validstrain(){
	if(form.companyname.value ==""){
		alert("Company name cannot be blank") 
		form.companyname.focus()
		return false;
	}
	if(form.contactname.value ==""){
		alert("Contact name cannot be blank") 
		form.contactname.focus()
		return false;
	}
	if(form.phonenum.value ==""){
		alert("Phone number cannot be blank") 
		form.phonenum.focus()
		return false;
	}
	if(form.faxnum.value ==""){
		alert("Fax number cannot be blank") 
		form.faxnum.focus()
		return false;
	}
	
	if(form.email.value ==""){
		alert("Email cannot be blank") 
		form.email.focus()
		return false;
	}
	if(!isEmail(form.email.value)){
		alert("Please enter a valid email address") 
		form.email.focus()
		return false;
	}
	if(form.product.options[form.product.selectedIndex].value ==""){
		alert("Please select a product") 
		form.product.focus()
		return false;
	}
	if(form.datd.value ==""){
		alert("Preferred Date cannot be blank")
		return false;
	}
	if(form.employ.value ==""){
		alert("The number of emplyees cannot be blank") 
		form.employ.focus()
		return false;
	}
	else{
		for (i = 0;  i < form.employ.value.length;  i++) {
			ch = form.employ.value.charAt(i);  
			if (ch != "0" ) {
				if (ch != "1" ) {
					if (ch != "2" ) {
						if (ch != "3" ) {
							if (ch != "4" ) {  
								if (ch != "5" ) { 
									if (ch != "6" ) { 
										if (ch != "7" ) { 
											if (ch != "8" ) { 
												if (ch != "9" ) {
													alert("The number of employees must be a number");
													form.employ.focus()
													return false;
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}				
		}
	}
	if(confirm("Have you checked the details you have entered are correct?")){
		return true;
	}
	else{
		return false;
	}
}
function validgtrain(){
	if(form.companyname.value ==""){
		alert("Company name cannot be blank") 
		form.companyname.focus()
		return false;
	}
	if(form.contactname.value ==""){
		alert("Contact name cannot be blank") 
		form.contactname.focus()
		return false;
	}
	if(form.phonenum.value ==""){
		alert("Phone number cannot be blank") 
		form.phonenum.focus()
		return false;
	}
	else{
		if (!checknumber(form.phoneaxnum) ) {
				alert("The fax number must be a number including: ()+-. for example +353-(0)-1-401-1833 ");
				form.phonenum.focus()
				return false;
			}
	}
	if(form.faxnum.value ==""){
		alert("Fax number cannot be blank") 
		form.faxnum.focus()
		return false;
	}
	
	if(form.email.value ==""){
		alert("Email cannot be blank") 
		form.email.focus()
		return false;
	}
	if(!isEmail(form.email.value)){
		alert("Please enter a valid email address") 
		form.email.focus()
		return false;
	}
	if(confirm("Have you checked the details you have entered are correct?")){
		return true;
	}
	else{
		return false;
	}
}
function validst(){
	if(form.company.value ==""){
		alert("Company name cannot be blank") 
		form.company.focus()
		return false;
	}
	if(form.phonenum.value ==""){
		alert("Phone number cannot be blank") 
		form.phonenum.focus()
		return false;
	}
	if(form.faxnum.value ==""){
		alert("Fax number cannot be blank") 
		form.faxnum.focus()
		return false;
	}
	
		if(form.contact.value ==""){
		alert("Contact name cannot be blank") 
		form.contact.focus()
		return false;
	}
	if(form.email.value ==""){
		alert("Email cannot be blank") 
		form.email.focus()
		return false;
	}
	if(!isEmail(form.email.value)){
		alert("Please enter a valid email address") 
		form.email.focus()
		return false;
	}
	if(form.pur.value ==""){
		alert("Purchase order number cannot be blank") 
		form.pur.focus()
		return false;
	}
	
	if(confirm("Have you checked the details you have entered are correct?")){
		return true;
	}
	else{
		return false;
	}
}
function validsp(){
	if(form.companyname.value ==""){
		alert("Company name cannot be blank") 
		form.companyname.focus()
		return false;
	}
	if(form.contactname.value ==""){
		alert("Contact name cannot be blank") 
		form.contactname.focus()
		return false;
	}
	if(form.phonenum.value ==""){
		alert("Phone number cannot be blank") 
		form.phonenum.focus()
		return false;
	}
	if(form.faxnum.value ==""){
		alert("Fax number cannot be blank") 
		form.faxnum.focus()
		return false;
	}
	
	if(form.email.value ==""){
		alert("Email cannot be blank") 
		form.email.focus()
		return false;
	}
	if(!isEmail(form.email.value)){
		alert("Please enter a valid email address") 
		form.email.focus()
		return false;
	}
	if(form.product.options[form.product.selectedIndex].value ==""){
		alert("Please select a product") 
		form.product.focus()
		return false;
	}
	if(form.msg.value ==""){
		alert("Please enter a message or question") 
		form.msg.focus()
		return false;
	}
	if(confirm("Have you checked the details you have entered are correct?")){
		return true;
	}
	else{
		return false;
	}
}
function validcu(){
	if(form.to.options[form.to.selectedIndex].value ==""){
		alert("Please select the department you want to email") 
		form.to.focus()
		return false;
	}
	if(form.companyname.value ==""){
		alert("Company name cannot be blank") 
		form.companyname.focus()
		return false;
	}
	if(form.contactnam.value ==""){
		alert("Contact name cannot be blank") 
		form.contactnam.focus()
		return false;
	}
	if(form.phonenum.value ==""){
		alert("Phone number cannot be blank") 
		form.phonenum.focus()
		return false;
	}
	
			
	if(form.faxnum.value ==""){
		alert("Fax number cannot be blank") 
		form.faxnum.focus()
		return false;
	}
	
	if(form.email.value ==""){
		alert("Email cannot be blank") 
		form.email.focus()
		return false;
	}
	if(!isEmail(form.email.value)){
		alert("Please enter a valid email address") 
		form.email.focus()
		return false;
	}
	
	if(form.msg.value ==""){
		alert("Please enter a message or question") 
		form.msg.focus()
		return false;
	}
	if(confirm("Have you checked the details you have entered are correct?")){
		return true;
	}
	else{
		return false;
	}
}
function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  //
  //  Regular expressions are supported
  //
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str))}
	function char(){
		
		if (window.event){
			 key = window.event.keyCode;
		}
		if (key == 60 || key == 62){
			alert("The character '"+String.fromCharCode(key)+"' is not allowed");
			return false;
		}
	
	}
