

	var error=0;
function check(obj,type){

	if(type=='empty' && obj.value.length<1){
		$(obj.id+'val').empty();
				var cityhc = new Element('span', {'class':'Kirmizi8Bold','text':'Required Field','id':obj.id+'val' }).inject(obj, 'after');
				
	error++;
	}else if(type=='email' && isEmail(obj.value)==false){
		$(obj.id+'val').empty();
				var cityhc = new Element('span', {'class':'Kirmizi8Bold','text':'Please enter a valid email address','id':obj.id+'val' }).inject(obj, 'after');
				error++;
	}else if(type=='emailval' && obj.value!=$('email').value){
		$(obj.id+'val').empty();
				var cityhc = new Element('span', {'class':'Kirmizi8Bold','text':'Email addresses do not match','id':obj.id+'val' }).inject(obj, 'after');
				error++;
	}else if(type=='tel' && ($('tel').value.length<7 && $('mobile').value.length<7)){
		$('telval').empty();
		var cityhc = new Element('span', {'class':'Kirmizi8Bold','text':'Required Field'}).inject($('telval'));
		error++;
				
	}else{
	if(type=='tel')$('telval').empty();
	 else $(obj.id+'val').empty();
					}		
		}
		function isEmail(str) {

   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = str;
   if(reg.test(address) == false) {
      return false;
   }
        
}

function getDialingCode(cc){
	var req = new Request({url:'/query/getCC', 
		onSuccess: function(html) {
			//Clear the text currently inside the results div.
			$('CountryCode').set('value','+'+html);
			//Inject the new DOM elements into the results div.
			$('CountryCodeMobile').set('value','+'+html);
		},
		//Our request will most likely succeed, but just in case, we'll add an
		//onFailure method which will let the user know what happened.
		onFailure: function() {
			$('result').set('text', 'The request failed.');
		}
	});
	var val="op=getDialingCode&cc="+cc;
	
		req.send(val);
	
	
}
function deleteFile(fn){
	var req = new Request({url:'query/deleteFile', 
		onSuccess: function(html) {

},
		//Our request will most likely succeed, but just in case, we'll add an
		//onFailure method which will let the user know what happened.
		onFailure: function() {
			$('result').set('text', 'The request failed.');
		}
	});
	var val="op=deleteFile&fileName="+fn;
	
		req.send(val);
	
	
}

function addFile(fn,fnn){
	var req = new Request({url:'/guides/query/addFile', 
		onSuccess: function(html) {
			//Clear the text currently inside the results div.
		},
		//Our request will most likely succeed, but just in case, we'll add an
		//onFailure method which will let the user know what happened.
		onFailure: function() {
			$('result').set('text', 'The request failed.');
		}
	});
	var val="op=addFile&fileName="+fn+"&newName="+fnn;
	
		req.send(val);
	
	
}


function checkThemAll(){
	error=0;
check($('firstname'),'empty');
check($('lastname'),'empty');
check($('email'),'email');
check($('emailvalidate'),'emailval');
check($('tel'),'tel');
check($('whentreatment'),'empty');
check($('security_code'),'empty');
check($('branch'),'empty');
if(error>0){alert('Please fill in all mendatory fields!');
return 0;}
		}


