var groco=new Array;

var stringHtml='<html><head><meta name="description" content="ClearWare print tool"/><meta name="keywords" content="k"/><meta name="author" content="office@clearware.eu"/><link href="css/pub_print.css" rel="stylesheet" /></head><body onload="javscript: window.print();"><div id="main">';
var stringHtmlEnd='</div></body></html>';
var PrintCommandObject = null;
function printIT(id){
	newWin = window.open('','a','width=780,height=500,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');
	var html = stringHtml+document.getElementById(id).innerHTML+stringHtmlEnd;
	newWin.document.write(html);
	newWin.document.close();
	newWin.focus();
}
function showBubbleExt(uID){
	document.getElementById('moreUserInfo'+uID).style.display='';
	$('#moreUserInfo'+uID).css( 'top', (($('#rowUser'+uID).offset().top-$('#moreUserInfo'+uID).height())-3)+'px');
	return true;
}
function hideBubbleExt(uID){
	document.getElementById('moreUserInfo'+uID).style.display='none';
	return true;
}

function getMultiSelectVals(selName){
	var out = new Array;
	for(var k=0; k<selName.childNodes.length; k++)
		if(selName.childNodes[k].selected){
			out.push(selName.childNodes[k].value);
		}
	return out;
}
function createFormArray1(form_id){
	var obj = document.getElementById(form_id);
	return workFormArray(obj);
}
function createFormArray_Obj(obj){
	return workFormArray(obj);
}
function workFormArray(myForm){
	var inputs = myForm.elements;
	var out = new Array();
	for (var i=0; i<inputs.length; i++){
		if(inputs[i].name && inputs[i].name!=''){
			if(inputs[i].name.indexOf('[]')!=-1){
				if(out[inputs[i].name.replace('[]', '')]==undefined || out[inputs[i].name.replace('[]', '')].constructor.toString().indexOf("Array") == -1){
					out[inputs[i].name.replace('[]', '')]=new Array();
				}
				if(inputs[i].type=='checkbox' || inputs[i].type=='radio'){
					if(inputs[i].checked){
						out[inputs[i].name.replace('[]', '')].push(inputs[i].value);
					}
				}else{
					out[inputs[i].name.replace('[]', '')].push(inputs[i].value);
				}
			}else if (inputs[i].type=='checkbox'){
				out[inputs[i].name]=(inputs[i].checked)?inputs[i].value:'';
			}else if(inputs[i].type=='radio'){
				if(inputs[i].checked)
					out[inputs[i].name]=inputs[i].value;
			}else if (inputs[i].type=='select-multiple'){
				out[inputs[i].name]= getMultiSelectVals(inputs[i]);
			}else{
				out[inputs[i].name]=inputs[i].value;
			}
		}
	}
	return out;
}

function validateContact(f){
	var e=f.elements;
	for(var i=0; i<e.length; i++){
		if(e[i].value==''){
			alert(EmptyValMess);
			e[i].focus();
			return false;
		}
		if(e[i].name=='email'){
			var reMail = /^[A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+\.[A-Za-z]{2,4}$/;
			if(!reMail.exec(e[i].value)){
				alert(WrongMailMess);
				e[i].focus();
				return false;
			}
		}
	}
	return true;
}
function setDisabled(){
	$("#pub_tint").fadeIn("slow");
}
function setEnabled(){
	$("#pub_tint").fadeOut("slow");
}

function ChangeID(nachschlag, clone){
	for (var i=0; i<=clone.childNodes.length; i++){
		if(clone.childNodes[i]){
			if(clone.childNodes[i].id && clone.childNodes[i].id!=''){
				clone.childNodes[i].id=clone.childNodes[i].id+nachschlag;
			}
			ChangeID(nachschlag, clone.childNodes[i]);
		}
	}
}
function logger(string){
// 	if (!loggerWin){
// 		var loggerWin=window.open('','a','toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');
// 		var d=loggerWin.document.createElement('div');
// 		d.id="loggerHold";
// 		loggerWin.document.body.appendChild(d);
// 	}
// 	loggerWin.document.getElementById('loggerHold').innerHTML=string+'<br/>'+loggerWin.document.getElementById('loggerHold').innerHTML;
}
function print_r(array){
	out='';
	for(var i in array){
	if(typeof array[i]=='object'){
	//if(array[i].constructor && array[i].constructor.toString().indexOf("Array")>-1)
		out+='\t'+i+'(array){\n\t'+print_r(array[i])+'\n}\n';
	}else
		out+='\n'+i+'='+array[i]+'\n'
	}
	return out;
}

function hidePopup(){
	$("#pub_popup").hide();
	$("#pub_popupHolder").hide();
}
function showPopupClone(id, myWidth){
	if(!myWidth){
		var myWidth=460;
	}
	var docWid=$(document).width();
	var docOff=(document.all)?document.body.scrollTop:window.pageYOffset;

	var clone=document.getElementById(id).cloneNode(true);
	clone.id=clone.id+'d';
	clone.style.display='block';
	ChangeID('d', clone);
	$("#pub_popup").html('');
	$("#pub_popup").append(clone);

	$("#pub_popup").css({ left:'50%',  width:myWidth+'px',  marginLeft:Math.round(myWidth/2)*-1+'px'});
	$("#pub_popup").show();
	$("#pub_popupHolder").css({ left:'50%',  width:myWidth+'px',  marginLeft:Math.round(myWidth/2)*-1+'px'});
	$("#pub_popupHolder").show();
}

function showPopup(ht, myWidth){
	if(!myWidth){
		var myWidth=460;
	}
	var myPos=this1.offset();
	var docWid=$(document).width();
	var docOff=(document.all)?document.body.scrollTop:window.pageYOffset;

	$("#pub_popup").html(ht);

	$("#pub_popup").css({ left:'50%', width:myWidth+'px',  marginLeft:Math.round(myWidth/2)*-1+'px'});
	$("#pub_popupHolder").css({ left:'50%', width:myWidth+'px',  marginLeft:Math.round(myWidth/2)*-1+'px'});
	$("#pub_popupHolder").show();
	$("#pub_popup").show();
// 	$("#pub_popupHolder").fadeIn();
}

//regForm Functions
function checkPassSecure(){
	var midSecureS="(?=.*\\d)(?=.*[a-z])(?!.*"+document.getElementById('username_ob').value+").{5,}";
	var hiSecureS="(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?!.*"+document.getElementById('username_ob').value+").{5,}";
	var vhiSecureS="(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\\W)(?!.*"+document.getElementById('username_ob').value+").{7,}";
	var midSecure=new RegExp(midSecureS, "");
	var hiSecure=new RegExp(hiSecureS, "");
	var vhiSecure=new RegExp(vhiSecureS, "");
	var secLevel=1;
	if(vhiSecure.exec(document.getElementById('password').value)){
		var secLevel=4;
	}else	if(hiSecure.exec(document.getElementById('password').value)){
		var secLevel=3;
	}else if(midSecure.exec(document.getElementById('password').value)){
			secLevel=2;
	}
	switch(secLevel){
		case 1:
			$("div[@class='pub_pass_color']").css( { color:'#FF0000' });
			$("div[@class='pub_pass_color'] img").attr( {src:'/img/public/pass'+secLevel+'.gif'} );
			document.getElementById('passSecureName').innerHTML=Weak;
		break;
		case 2:
			$("div[@class='pub_pass_color']").css( { color:'#FF6600' });
			$("div[@class='pub_pass_color'] img").attr( {src:'/img/public/pass'+secLevel+'.gif'} );
			document.getElementById('passSecureName').innerHTML=Medium;
		break;
		case 3:
			$("div[@class='pub_pass_color']").css( { color:'#FFCC00' });
			$("div[@class='pub_pass_color'] img").attr( {src:'/img/public/pass'+secLevel+'.gif'} );
			document.getElementById('passSecureName').innerHTML=Strong;
		break;
		case 4:
			$("div[@class='pub_pass_color']").css( { color:'#00CC00' });
			$("div[@class='pub_pass_color'] img").attr( {src:'/img/public/pass'+secLevel+'.gif'} );
			document.getElementById('passSecureName').innerHTML=VeryStrong;
		break;
	}
}
function validate_pass(){
	if(document.getElementById('oldPassd').value==''){
		alert(emptyVal);
		document.getElementById('oldPassd').focus();
		return false;
	}else if(document.getElementById('confirmd').value==''){
		alert(emptyVal);
		document.getElementById('confirmd').focus();
		return false;
	}else if(document.getElementById('password').value==''){
		alert(emptyVal);
		document.getElementById('password').focus();
		return false;
	}else if(document.getElementById('password').value!=document.getElementById('confirmd').value){
		alert(wrongConf);
		document.getElementById('password').focus();
		return false;
	}else if(document.getElementById('password').value.length<5){
		alert(fiveChars);
		document.getElementById('password').focus();
		return false;
	}else if(document.getElementById('password').value.indexOf(document.getElementById('username_ob').value)>-1){
		alert(nousernameinpass);
		document.getElementById('password').focus();
		return false;
	}else{
		return true;
	}
}
function validate(formID){
	if(!formID)
		formID='userReg';
	var reMail = /^[A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+\.[A-Za-z]{2,4}$/;
	var inputs=document.getElementById(formID).elements;
	var isFirm=document.getElementById('isFirmDa').checked;


	for(var i=0; i<inputs.length; i++){
		var cErrMess='';
		var myLabel=$("label", inputs[i].parentNode.previousSibling).html();
		if(myLabel!=null && myLabel.indexOf('<')>-1)
			var myLabel=myLabel.substring(0, myLabel.indexOf('<'));
		if(inputs[i].getAttribute('errMess') && inputs[i].getAttribute('errMess')!='')
			var cErrMess=inputs[i].getAttribute('errMess');
			
		if(inputs[i].id.indexOf('_ob') >-1){
			if((inputs[i].id.indexOf('_icl') ==-1 && inputs[i].id.indexOf('_if') ==-1) || (inputs[i].id.indexOf('_icl') >-1 && !isFirm) || (inputs[i].id.indexOf('_if') >-1 && isFirm)){


				if(inputs[i].value==''){
					alert((cErrMess=='')?(emptyVal+' '+myLabel):cErrMess);
					inputs[i].focus();
					return false;
				}else if(inputs[i].id.indexOf('_em')>-1 && !reMail.exec(inputs[i].value)){
					alert((cErrMess=='')?wrongMail:cErrMess);
					inputs[i].focus();
					return false;
				}else if(inputs[i].id.indexOf('_n')>-1 && isNaN(inputs[i].value)){
					alert((cErrMess=='')?(wrongDigit+' '+myLabel):cErrMess);
					inputs[i].focus();
					return false;
				}else if(inputs[i].id.indexOf('_d')>-1){
					var splitnq=inputs[i].value.split('.');
					if(splitnq.length!=3 || isNaN(splitnq[0]) || isNaN(splitnq[1]) || isNaN(splitnq[2]) || splitnq[0]<1 || splitnq[0]>31 || splitnq[1]<1 || splitnq[1]>12 || splitnq[2]<1900 || splitnq[2]>2010){
						alert(wrongDate);
						inputs[i].focus();
						return false;
					}
				}else if(formID=='userReg' && inputs[i].name=='e_mail' && checkVal('EMail', inputs[i].value, -2)){
					alert((cErrMess=='')?wrongE_Mail:cErrMess);
					inputs[i].focus();
					return false;
				}else if(formID=='userReg' && inputs[i].name=='username' && checkVal('User', inputs[i].value, -2)){
					alert((cErrMess=='')?wrongUser:cErrMess);
					inputs[i].focus();
					return false;
				}else if(formID=='userReg' && inputs[i].name=='number' && xoadObj.checkLicence_ajax({number:inputs[i].value , licenceDate:document.getElementById('licenceDate_ob_d').value , agencyID:document.getElementById('agencyID').value , licenceID:0})){
					alert((cErrMess=='')?wrongLic:cErrMess);
					inputs[i].focus();
					return false;
				}else if(formID=='licance1Popup11Formd' && inputs[i].name=='number' && xoadObj.checkLicence_ajax({number:inputs[i].value , licenceDate:document.getElementById('licenceDate_pup_ob_d').value , agencyID:document.getElementById('agencyID_pupd').value , licenceID:document.getElementById('licenceID_pupd').value})){
					alert((cErrMess=='')?wrongLic:cErrMess);
					inputs[i].focus();
					return false;
				}
			}
		}
  if(inputs[i].id.indexOf('_ft')>-1 && !checkFileType(inputs[i].value)){
    alert((cErrMess=='')?(wrongFile+' '+myLabel):cErrMess);
    inputs[i].focus();
    return false;
  }
	}
	if(ii==0){
		if(document.getElementById('confirm').value==''){
			alert((cErrMess=='')?(emptyVal+' '+myLabel):cErrMess);
			document.getElementById('confirm').focus();
			return false;
		}else if(document.getElementById('password').value==''){
			alert((cErrMess=='')?(emptyVal+' '+myLabel):cErrMess);
			document.getElementById('password').focus();
			return false;
		}else if(document.getElementById('password').value!=document.getElementById('confirm').value){
			alert((cErrMess=='')?wrongConf:cErrMess);
			document.getElementById('password').focus();
			return false;
		}else if(document.getElementById('password').value.length<5){
			alert((cErrMess=='')?fiveChars:cErrMess);
			document.getElementById('password').focus();
			return false;
		}else if(document.getElementById('password').value.indexOf(document.getElementById('username_ob').value)>-1){
			alert((cErrMess=='')?nousernameinpass:cErrMess);
			document.getElementById('password').focus();
			return false;
		}
	}
	return true;
}
function checkVal(prop, val, uID){
	return xoadObj['check'+prop+"_ajax"](val, uID);
}
function dynCheckMail(){
	if(xoadObj.checkEMail_ajax(document.getElementById('e_mail_ob_em').value, -2)){
		document.getElementById('EMSpan').innerHTML='<img src="/img/public/hint.jpg" border="0" style="display: inline; height: 18px;"/>';
		document.getElementById('e_mail_ob_em').style.width='116px';
		document.getElementById('e_mail_ob_em').style.color='#ff0000';
	}else{
		document.getElementById('EMSpan').innerHTML='<img src="/img/public/active.jpg" border="0" style="display: inline; height: 18px;"/>';
		document.getElementById('e_mail_ob_em').style.width='116px';
		document.getElementById('e_mail_ob_em').style.color='#009933';
	}
}
function dynCheckUser(){
	if(xoadObj.checkUser_ajax(document.getElementById('username_ob').value, -2)){
		document.getElementById('UsSpan').innerHTML='<img src="/img/public/hint.jpg" border="0" style="display: inline; height: 18px;"/>';
		document.getElementById('username_ob').style.width='116px';
		document.getElementById('username_ob').style.color='#ff0000';
	}else{
		document.getElementById('UsSpan').innerHTML='<img src="/img/public/active.jpg" border="0" style="display: inline; height: 18px;"/>';
		document.getElementById('username_ob').style.width='116px';
		document.getElementById('username_ob').style.color='#009933';
	}
}


function showLeptuh(oblName, e){
	var of=$("#pub_masta").offset();
	mTop=e.pageY;
	mLeft=e.pageX-of['left']+7;
	document.getElementById('pub_leptuh').style.display='block';
	document.getElementById('pub_leptuh').style.top=mTop+'px';
	document.getElementById('pub_leptuh').style.left=mLeft+'px';
	document.getElementById('leptuhNameHolder').innerHTML=oblName;
}
function hideLeptuh(){
	document.getElementById('pub_leptuh').style.display='none';
}
$(document).ready(function(){
	$('area').mouseover(function(e){
		showLeptuh($(this).attr('alt'), e);
	});
	$('area').mousemove(function(e){
		showLeptuh($(this).attr('alt'), e);
	});
	$('area').mouseout(function(e){
		hideLeptuh();
	});
	$('a[id^=showExtBubble]').mouseover(function(){
		return showBubbleExt(this.id.split('_')[1]);
	});
	$('a[id^=showExtBubble]').mouseout(function(){
		return hideBubbleExt(this.id.split('_')[1]);
	});
	$(".showBubble").mouseover(function(e){
		if(!$('input.showBubble')[0] || ($('input.showBubble')[0] && $('input.showBubble')[0].disabled)){
			var o=$("#pub_masta").offset();
			$('#leptuh11').css(
				{
					position: 'absolute',
					display: 'block',
					top: e.pageY+'px',
					left: (e.pageX-o.left)+'px'
				}
			);
		}
	});
	$(".showBubble").mouseout(function(e){
		$('#leptuh11').css({display:'none'});
	});
});

function oblastChanged(to, holder){
	xoadObj.getAreasByStateID_ajax(to, 1, function(res){oblastChanged1(res, holder)});
}
function oblastChanged1(res, holder){
	var sel=document.getElementById(holder);
	emptySel(sel);
	var lng=res.length;
	var opt=document.createElement('option');
	opt.setAttribute('value', '');
	opt.appendChild(document.createTextNode('---'+chooseArea+'---'));
	sel.appendChild(opt);
	for(var i=0; i<lng; i++){
		var opt=document.createElement('option');
		opt.setAttribute('value', res[i]['id']);
		opt.appendChild(document.createTextNode(res[i]['name']));
		sel.appendChild(opt);
	}
}
function emptySel(sel){
	for(var j=sel.childNodes.length-1; j>0; j--){
		sel.removeChild(sel.childNodes[j]);
	}
}
function showObshtinaPup(){
	showPopupClone('obshtinaHolder', 460);
}
function showDeinostPup(){
	showPopupClone('deinostHolder', 460);
}
function addObshtinaPayment(){
	var params=createFormArray1('oblastPopupFormd');
	var datad=new Array();
// 	alert(print_r(params));
	datad['payservID']=2;
	datad['productID']=params['areaID'];
	addToCart(datad);
	hidePopup();
}
function addDeinostPayment(){
	var params=createFormArray1('deinostPopupFormd');
	var datad=new Array();
// 	alert(print_r(params));
	datad['payservID']=1;
	datad['productID']=params['activityID'];
	addToCart(datad);
	hidePopup();
}
function addObshtinaPaymentExt(id){
	var datad=new Array();
	var params=new Array();
	params[0]=id;
	datad['payservID']=2;
	datad['productID']=params;
	addToCart(datad);
}
function addDeinostPaymentExt(id){
	var datad=new Array();
	var params=new Array();
	params[0]=id;
	datad['payservID']=1;
	datad['productID']=params;
	addToCart(datad);
}
function addExt(bool){
	document.getElementById('first10').disabled=!bool;
	if(bool){
		var datad=new Array();
	// 	alert(print_r(params));
		datad['payservID']=3;
		datad['productID']=0;
		addToCart(datad);
	}else{
		xoadObj.del_byType_ajax(3, refreshCart);
	}
}
function addFirst10f(bool){
	if(bool){
		var datad=new Array();
		datad['payservID']=4;
		datad['productID']=0;
		addToCart(datad);
	}else{
		xoadObj.del_byType_ajax(4, refreshCart);
	}
}
function addToCart(datad){
	document.getElementById('cartHolder').style.display='block';
	xoadObj.add_plashtane_ajax(datad, refreshCart);
}
function refreshCart(res){
	document.getElementById('cartTableHolder').innerHTML=res;
}
function delRow(pos){
	xoadObj.del_plashtane_ajax(pos, refreshCart);
}
function editCart(){
	var datad=createFormArray1('cartForm');
// 	alert(print_r(datad));
	xoadObj.edit_quantity_ajax(datad, refreshCart);
}
function validateCart(formID){
	var zeForm=document.getElementById(formID);
	$('input',zeForm).each(function(){
		if($(this).attr('minval') && $(this).attr('minval')*1 > this.value*1){
			alert('Въведената стойност в полето количество е по-малка от минималната разрешена ('+$(this).attr('minval')+')');
			this.focus();
			return false;
		}
	});
}
function showLicenceHolder(licID){
	showPopupClone('licencesPopup', 460);
	if(licID>0)
		xoadObj.licence_getByID_ajax(licID, loadLic);
	else
		loadLic(0)
}
function loadLic(res){
	document.getElementById('nnumber_ob_nd').value=(res!=0)?res['number']:'';
	document.getElementById('licenceDate_pup_ob_d').value=(res!=0)?res['licenceDate_human']:'';
	document.getElementById('agencyID_pupd').value=(res!=0)?res['agencyID']:'';
	document.getElementById('picsHolder_pupd').innerHTML=(res!=0)?res['html']:'';
	document.getElementById('licenceID_pupd').value=(res!=0)?res['licenceID']:'0';
}
function saveLicence(){
	if(validate('licance1Popup11Formd')){
		var datad=createFormArray1('licance1Popup11Formd');
		xoadObj.licence_insert_ajax(datad, refreshLicence);
		hidePopup();
	}
}
function refreshLicence(res){
	document.getElementById('regLicenceHolder').innerHTML=res;
}
function delLicence(licID){
	xoadObj.licence_delete_ajax(uID, licID, refreshLicence);
}
function picUploaded(file){
	var fil=file.split('/');
	var f=fil[fil.length-1];
	xoadObj.licence_uploadPic_ajax(document.getElementById('licenceID_pupd').value,f, listPics);
}
function listPics(res){
	document.getElementById('picsHolder_pupd').innerHTML=res['html'];
	document.getElementById('licenceID_pupd').value=res['ID'];
}
function delPic(imgID){
	if(confirm(DelConfPUBPIC))
		xoadObj.licence_delPic_ajax(document.getElementById('licenceID_pupd').value, imgID, listPics);
}
function showSMenu(th, wmID){
	clearTimeout(groco['a'+wmID]);
	var mOf=$("#pub_masta").offset();
	var of=$(th).offset();
	document.getElementById('subMenu'+wmID).style.left=(of['left']-mOf['left']+10)+'px';
	document.getElementById('subMenu'+wmID).style.top=of['top']+24+'px';
	document.getElementById('subMenu'+wmID).style.display='block';
}
function hideSMenu(th, wmID){
	groco['a'+wmID]=setTimeout("hideSMenu1("+wmID+");", 200);
}
function hideSMenu1(wmID){
	document.getElementById('subMenu'+wmID).style.display='none';
}
function delLogo(){
	document.getElementById('logoInpHolder').style.display='block';
	document.getElementById('logoIconHolder').style.display='none';
	xoadObj.user_delLogo_ajax(uID);
}
function setFirmChl(isF){
	var setCHL='block';
	var setIF='none';
	if(isF==1){
		var setCHL='none';
		var setIF='block';
	}
	$("div[id$='_if']").css({display: setIF});
	$("div[id$='_ichl']").css({display: setCHL});
}
function dynUpdateBanks(el, hold){
	var str='';
	var template='<div style="margin-bottom: 7px;"><img src="/img/public/banks/_val_bank.gif" style="margin-right: 10px; vertical-align: middle; width: 25px; padding: 2px; border: 1px solid gray;" alt="_name_" title="_name_"/>_name_</div>';
	for(var i=0; i<el.childNodes.length; i++){
		if(el.childNodes[i].selected){
			str+=template.replace(/_val_/ig, el.childNodes[i].value).replace(/_name_/ig, el.childNodes[i].innerHTML);
		}
	}
	document.getElementById(hold).innerHTML=str;
}

function oblastChangedSear(to){
	xoadObj.getAreasByStateID_ajax(to, oblastChangedSear1);
}
function oblastChangedSear1(res){
	var sel=document.getElementById('areaID');
	emptySel(sel);
	var lng=res.length;
	var opt=document.createElement('option');
	opt.setAttribute('value', '');
	opt.appendChild(document.createTextNode('---'+chooseArea+'---'));
	sel.appendChild(opt);
	for(var i=0; i<lng; i++){
		var opt=document.createElement('option');
		opt.setAttribute('value', res[i]['id']);
		opt.appendChild(document.createTextNode(res[i]['name']));
		sel.appendChild(opt);
	}
}
function emptySel(sel){
	for(var j=sel.childNodes.length-1; j>=0; j--){
		sel.removeChild(sel.childNodes[j]);
	}
}
function validateSearch(){
	var mess=pleaseSel;
	if(document.getElementById('stateID').value==''){
		document.getElementById('stateID').focus();
		alert(mess);
		return false;
	}else if(document.getElementById('activityID').value==''){
		document.getElementById('activityID').focus();
		alert(mess);
		return false;
	}else if(document.getElementById('areaID').value==''){
		document.getElementById('areaID').focus();
		alert(mess);
		return false;
	}else{
		return true;
	}
}

function validateRequ(){
	var reMail = /^[A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+\.[A-Za-z]{2,4}$/;
	var inputs = document.getElementById('regForm').elements;
	for(var i=0; i< inputs.length; i++){
		if(inputs[i].value==''){
			alert(emptyVal);
			inputs[i].focus();
			return false;
		}
	}
	if(!reMail.exec(document.getElementById("email").value)){
		alert(wrongMail);
		document.getElementById("email").focus();
		return false;
	}else
		return true;
}

function validateCon(){
	var reMail = /^[A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+\.[A-Za-z]{2,4}$/;
	if(document.getElementById("email").value==''){
		alert(emptyVal);
		document.getElementById("email").focus();
		return false;
	}else if(!reMail.exec(document.getElementById("email").value)){
		alert(wrongMail);
		document.getElementById("email").focus();
		return false;
	}else
		return true;
}
function checkFileType(str){
	if(str=='')
		return true;
	var allowed='gif jpg png jpeg bmp tiff tif pdf';
 var str_arr=str.split('.');
 var ext=str_arr[str_arr.length-1].toLowerCase();
	return  (allowed.indexOf(ext) != -1);
}
