
function validateRegistration(theForm){
intAlertMsg = ""	
strAlertMsg = ""
focusField = ""     
     hasRandom0(theForm,'name1','Εταιρία ')
     hasRandom0(theForm,'name2','Όνομα Υπευθύνου ')
     hasSelected(theForm,'district','Νομός ')
     hasRandom0(theForm,'visiting_address','Διεύθυνση ')
     hasRandom0(theForm,'zipcode','Ταχυδρομικός Κώδικας ')
     hasRandom0(theForm,'city','Πόλη ')
     hasRandom0(theForm,'phone1','Τηλέφωνο 1 ')
     hasPassword(theForm,'passwd','passwd2','Κωδικός πρόσβασης ')


    if(strAlertMsg !=""){
          alert("Παρακαλούμε συμπληρώστε τα παρακάτω πεδία.\n\n" + strAlertMsg);
        return false;
    }

if(confirm("Is the given information correct? "))
	{

    return true;	
	}
	else
	{
	return false;
	}

}




function carFields(theForm){
strAlertMsg = ""
intAlertMsg = ""
focusField = ""              
     hasSelected(theForm,'brand','Μάρκα ')
     hasSelected(theForm,'fuel','Τύπος καυσίμων (εάν δεν γνωρίζεται, επιλέξτε το Δεν Έχει) ')     
     hasSelected(theForm,'cartype','Αμάξωμα ')          
     hasSelected(theForm,'model','Μοντέλο ')
     hasSelected(theForm,'mil','Χιλιόμετρα')      
     isNumeric(theForm,'price','Τιμή ')                   
     hasRandom0(theForm,'color','Χρώμα ')

	 if(intAlertMsg==1) {
	 	alert("Παρακαλούμε συμπληρώστε το πεδίο " + strAlertMsg);	 
	 	return false;
	}
	else if(intAlertMsg>1) {    
          alert("Παρακαλούμε συμπληρώστε τα παρακάτω πεδία\n\n" + strAlertMsg);
        return false;
    }
  

if(confirm("Is the given information correct? "))
	{

    return true;	
	}
	else
	{
	return false;
	}

}


function truckFields(theForm){
strAlertMsg = ""
intAlertMsg = ""
focusField = ""              
     hasSelected(theForm,'brand','Μάρκα ')
     hasRandom0(theForm,'rubric','Αμάξωμα ')     
     hasSelected(theForm,'fuel','Τύπος καυσίμων (εάν δεν γνωρίζεται, επιλέξτε το Δεν Έχει) ')     
     hasSelected(theForm,'model','Μοντέλο ')     
     hasSelected(theForm,'mil','Χιλιόμετρα ')      
     isNumeric(theForm,'price','Τιμή ')                                             


 if(intAlertMsg==1) {
	 	alert("Παρακαλούμε συμπληρώστε το πεδίο " + strAlertMsg);	 
	 	return false;
	}
	else if(intAlertMsg>1) {    
          alert("Παρακαλούμε συμπληρώστε τα παρακάτω πεδία\n\n" + strAlertMsg);
        return false;
    }

if(confirm("Is the given information correct? "))
	{

    return true;	
	}
	else
	{
	return false;
	}

}



function caravanFields(theForm){
strAlertMsg = ""
focusField = ""              
intAlertMsg = ""
     hasSelected(theForm,'brand','Μάρκα ')     
     hasSelected(theForm,'fuel','Τύπος καυσίμων (εάν δεν γνωρίζεται, επιλέξτε το Δεν Έχει) ')     
     hasSelected(theForm,'model','Αμάξωμα ')     
     isNumeric(theForm,'price','Τιμή ')                                             


 if(intAlertMsg==1) {
	 	alert("Παρακαλούμε συμπληρώστε το πεδίο " + strAlertMsg);	 
	 	return false;
	}
	else if(intAlertMsg>1) {    
          alert("Παρακαλούμε συμπληρώστε τα παρακάτω πεδία\n\n" + strAlertMsg);
        return false;
    }

if(confirm("Is the given information correct? "))
	{

    return true;	
	}
	else
	{
	return false;
	}

}


function mcFields(theForm){
intAlertMsg = ""
strAlertMsg = ""
focusField = ""              
     hasSelected(theForm,'brand','Μάρκα ')
     hasRandom0(theForm,'rubric','Αμάξωμα ')     
     hasSelected(theForm,'fuel','Τύπος καυσίμων (εάν δεν γνωρίζεται, επιλέξτε το Δεν Έχει) ')     
     hasSelected(theForm,'model','Τύπος ')     
     isNumeric(theForm,'price','Τιμή ')                                             


 if(intAlertMsg==1) {
	 	alert("Παρακαλούμε συμπληρώστε το πεδίο " + strAlertMsg);	 
	 	return false;
	}
	else if(intAlertMsg>1) {  
          alert("Παρακαλούμε συμπληρώστε τα παρακάτω πεδία\n\n" + strAlertMsg);
        return false;
    }

if(confirm("Is the given information correct? "))
	{

    return true;	
	}
	else
	{
	return false;
	}

}




function isNumeric(theForm,strFieldName,strMsg) {
     var objFormField = theForm.elements[strFieldName];
     var strValue = objFormField.value;	
  if (strValue.length<1 || !strValue.toString().match(/^[-]?\d*\.?\d*$/))  {  
          strAlertMsg += "- "+ strMsg +" \n"; 	
          intAlertMsg ++; 
  return false;
}
  return true;
}


// ------------------------------------------------------------------------------
// used to check fields so they are not empty

function hasRandom0(theForm,strFieldName,strMsg)     {
     var objFormField = theForm.elements[strFieldName];
     var strValue = objFormField.value;
     if(strValue.length<1){
          strAlertMsg += "- "+ strMsg +" \n";
          intAlertMsg ++;
	return false;
	}
	return true;
}

function hasSelected(theForm,strFieldName,strMsg)     {
     var objFormField = theForm.elements[strFieldName];
     if(objFormField.selectedIndex ==0)     {
          strAlertMsg += "- "+ strMsg +" \n";
          intAlertMsg ++;
           return false;
           }
     return true;

}


function hasPassword(theForm,strFieldName,strFieldName2,strMsg)     {
     var objFormField = theForm.elements[strFieldName];
     var objFormField2 = theForm.elements[strFieldName2];
     var strValue = objFormField.value;
     var strValue2 = objFormField2.value;
     if(strValue.length<1){
          strAlertMsg += "- "+ strMsg +" \n";          
	return false;
	}
     if(strValue != strValue2){
          strAlertMsg += "- "+ strMsg +"s must be the same\n";
	return false;
	}	
	
	
	return true;
}






function showLargeImage(strDisplayPath, ad_id, admin) {
	var ad_id = ad_id ? ad_id : "";
	var admin = admin ? admin : false;
	var image = document.getElementById("display_image" + ad_id).firstChild;
        
	

	if (admin) {
		resizeImage(image, strDisplayPath, null, admin);
		
	} else {
		if (navigator.userAgent.toLowerCase().indexOf('safari') > 0) {
			next_image = new Image;
			next_image.src = strDisplayPath;

			image.src = next_image.src;
			waitForNextImage(next_image, ad_id);
			
		} else {
			image.src = strDisplayPath;			
			//document.links.lightbox.href=strDisplayPath;
			
		}
	}
	
//document.getElementById('lightbox').location.href=strDisplayPath;
}




	
	// ----------------------------------------------------------------------------------------
// update select-boxes


	function updateKommunList(sLan,sField,sValue)
	{
			
		var type = "sok";
			
		var objArea = document.f1.elements[sLan];		
		var objKommun = document.f1.elements[sField];
		
		// Töm eventuella poster i kommunlistan
		while (objKommun.length > 0)
			objKommun[0] = null;
			
		var intSelectedIndex = objArea.selectedIndex;
		var intAreaID = parseInt(objArea.options[intSelectedIndex].value);
		var intCountKommun = 0;
			
		var intKommun = 0;
		var intStadsdel = 0;
		var arrKommunItem = new Array();
		var first = 0;

	if(arrKommun.length>0) {
			
		for (intKommun=0; intKommun<arrKommun.length; intKommun++)
		{
			arrKommunItem = arrKommun[intKommun].split(",");
			if (arrKommunItem[0] == intAreaID)
			{
			
				if(first==0) {
					objKommun.options.length = intCountKommun+1;
					objKommun.options[intCountKommun].text = "Όλα";
					objKommun.options[intCountKommun].value = "0";					
					first = 1;
				intCountKommun++;
				}
			
					objKommun.options.length = intCountKommun+1;
					objKommun.options[intCountKommun].text = arrKommunItem[2];
					objKommun.options[intCountKommun].value = arrKommunItem[1];						;
					if(document.f1.elements[sValue].value==arrKommunItem[1]) {
							
						objKommun.options[intCountKommun].selected = true
					}
					intCountKommun++;

	
			}		
		}
	}
		
	}









	// ----------------------------------------------------------------------------------------
// update select-boxes


	function updateBuyPage(sLan,sField,sValue,sPlacement)
	{
			
		var type = "sok";			
		var objArea = document.f1.elements[sLan];		
		var objKommun = document.f1.elements[sField];
		var objPlacement = document.f1.elements[sPlacement];
		
	
	
	
		// Töm eventuella poster i kommunlistan
		while (objKommun.length > 0)
			objKommun[0] = null;
			
			
		// Töm eventuella poster i placement
		while (objPlacement.length > 0)
			objPlacement[0] = null;
			
			
		var intSelectedIndex = objArea.selectedIndex;
		var intAreaID = parseInt(objArea.options[intSelectedIndex].value);
		var intCountKommun = 0;
			
		var intKommun = 0;
		var intStadsdel = 0;
		var arrKommunItem = new Array();
		var first = 0;





	if(arrKommun.length>0) {
			
		for (intKommun=0; intKommun<arrKommun.length; intKommun++)
		{
			arrKommunItem = arrKommun[intKommun].split(",");
			if (arrKommunItem[0] == intAreaID)
			{
			
				if(first==0) {
					objKommun.options.length = intCountKommun+1;			
					objKommun.options[intCountKommun].value = "0";										
					objKommun.options[intCountKommun].text = "Choose one...";										
					objKommun.options[intCountKommun].selected = true;
					first = 1;
				intCountKommun++;
				}
			
					objKommun.options.length = intCountKommun+1;
					objKommun.options[intCountKommun].text = arrKommunItem[2];
					objKommun.options[intCountKommun].value = arrKommunItem[1];						;
					intCountKommun++;

	
			}		
		}
	}



		
	}


		function updateKommunList1(sLan,sField,sValue,sPlacement)
	{
			
		var type = "sok";
			
		var objArea = document.f1.elements[sLan];
		var objKommun = document.f1.elements[sField];		
		var first = 0;
		
		// Töm eventuella poster i kommunlistan
		while (objKommun.length > 0)
			objKommun[0] = null;
			
		var intSelectedIndex = objArea.selectedIndex;
		var intAreaID = parseInt(objArea.options[intSelectedIndex].value);
		var intCountKommun = 0;
			
		var intKommun = 0;
		var intStadsdel = 0;
		var arrKommunItem = new Array();

			
		for (intKommun=0; intKommun<arrKommun1.length; intKommun++)
		{
			arrKommunItem = arrKommun1[intKommun].split(",");
			if (arrKommunItem[0] == intAreaID)
			{
				if(first==0) {

					objKommun.options.length = intCountKommun+1;
					objKommun.options[intCountKommun].text = "Choose one...";					
					objKommun.options[intCountKommun].value = "0";					
					first = 1;
				intCountKommun++;
				}


			
					objKommun.options.length = intCountKommun+1;
					objKommun.options[intCountKommun].text = arrKommunItem[2];
					objKommun.options[intCountKommun].value = arrKommunItem[1];						;
					if(document.f1.elements[sValue].value==arrKommunItem[1]) {
							
						objKommun.options[intCountKommun].selected = true
					}
					intCountKommun++;

	
			}
		}
	}







function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function hasRandom0(theForm,strFieldName,strMsg)     {
     var objFormField = theForm.elements[strFieldName];
     var strValue = objFormField.value;
     if(strValue.length<1){
          strAlertMsg += "- "+ strMsg +" \n";
          intAlertMsg ++;
	return false;
	}
	return true;
}


function sendMail(theForm){		
strAlertMsg = ""
focusField = ""     
     hasRandom0(theForm,'ymail','Your email ')
     hasRandom0(theForm,'vmail','Your friends email ')
    if(strAlertMsg !=""){
          alert("Error occured!\n\n" + strAlertMsg);
        return false;
    }
			theForm.submit();
}



	function delete_brand () {
		tmp=false;		
		tmp = confirm ('Delete this brand?');	
		return tmp;
	}



	function delete_equipment () {
		tmp=false;		
		tmp = confirm ('Delete this equipment?');	
		return tmp;
	}

