// JavaScript Document


/*
 JavaScript Clear Textfield Default Value onClick
 */
function clearText(field){
    if (field.defaultValue == field.value) 
        field.value = '';
    else 
        if (field.value == '') 
            field.value = field.defaultValue;
}





function checkform(){
    /*	if (documnet.ge)
     {
     // something is wrong
     alert('There is a problem with the first field');
     return false;
     }
     else if (value of next field is or isn't something)
     {
     // something else is wrong
     alert('There is a problem with...');
     return false;
     }
     // If the script gets this far through all of your fields
     // without problems, it's ok and you can submit the form
     */
    return true;
}

function checkform(form){
    if (document.form.name.value == "" || document.form.name.value == document.form.name.defaultValue) {
        alert("Παρακαλώ συμπληρώστε το όνομα σας.");
        document.form.name.focus();
        return false;
    }
    else 
        if (document.form.email.value == "" || document.form.email.value == document.form.email.defaultValue) {
            alert("Παρακαλώ συμπληρώστε το e-mail σας.");
            document.form.email.focus();
            return false;
        }
        else 
            if (document.form.brand.value == "" || document.form.brand.value == document.form.brand.defaultValue) {
                alert("Παρακαλώ συμπληρώστε την μάρκα.");
                document.form.brand.focus();
                return false;
            }
            else 
                if (document.form.fuel.value == "" || document.form.fuel.value == document.form.fuel.defaultValue) {
                    alert("Παρακαλώ συμπληρώστε το είδος καυσίμου.");
                    document.form.fuel.focus();
                    return false;
                }
                else 
                    if (document.form.model.value == "" || document.form.model.value == document.form.model.defaultValue) {
                        alert("Παρακαλώ συμπληρώστε το μοντέλο.");
                        document.form.model.focus();
                        return false;
                    }
                    else 
                        if (document.form.type.value == "" || document.form.type.value == document.form.type.defaultValue) {
                            alert("Παρακαλώ συμπληρώστε το είδος κατασκεύης.");
                            document.form.type.focus();
                            return false;
                        }
                        else 
                            if (document.form.priceFrom.value == "" || document.form.priceFrom.value == document.form.priceFrom.defaultValue) {
                                alert("Παρακαλώ συμπληρώστε το πεδίο τιμή από");
                                document.form.priceFrom.focus();
                                return false;
                            }
                            else 
                                if (document.form.priceTo.value == "" || document.form.priceTo.value == document.form.priceTo.defaultValue) {
                                    alert("Παρακαλώ συμπληρώστε το πεδίο τιμή εώς");
                                    document.form.priceTo.focus();
                                    return false;
                                }
                                else 
                                    if (document.form.kmFrom.value == "" || document.form.kmFrom.value == document.form.kmFrom.defaultValue) {
                                        alert("Παρακαλώ συμπληρώστε το πεδίο χιλιόμετρα από");
                                        document.form.kmFrom.focus();
                                        return false;
                                    }
                                    else 
                                        if (document.form.kmTo.value == "" || document.form.kmTo.value == document.form.kmTo.defaultValue) {
                                            alert("Παρακαλώ συμπληρώστε το πεδίο χιλιόμετρα εώς");
                                            document.form.kmTo.focus();
                                            return false;
                                        }
                                        else 
                                            if (document.form.description.value == "" || document.form.description.value == document.form.description.defaultValue) {
                                                alert("Παρακαλώ συμπληρώστε την επιπλέον περιγραφή σας");
                                                document.form.description.focus();
                                                return false;
                                            }
                                            else 
                                                if (document.form.telephone.value == "" || document.form.telephone.value == document.form.telephone.defaultValue) {
                                                    alert("Please enter your telephone.");
                                                    document.form.telephone.focus();
                                                    return false;
                                                }
                                                else 
                                                    if (document.form.message.value == "" || document.form.message.value == document.form.message.defaultValue) {
                                                        alert("Please enter yourmessage.");
                                                        document.form.message.focus();
                                                        return false;
                                                    }
    // ** End checkform **
    return true;
}

function checkContactForm(form){
    if (document.form.name.value == "" || document.form.name.value == document.form.name.defaultValue) {
        alert("Please fill out your name.");
        document.form.name.focus();
        return false;
    }
    else 
        if (document.form.email.value == "" || document.form.email.value == document.form.email.defaultValue) {
            alert("Please fill out your email address.");
            document.form.email.focus();
            return false;
        }
        else 
            if (!check_email('email')) {
                alert("Please enter a valid email address.");
                document.form.email.focus();
                return false;
            }
            else 
                if (document.form.txtNumber.value == "" || document.form.txtNumber.value == document.form.txtNumber.defaultValue) {
                    alert("Please fill out your security code.");
                    document.form.txtNumber.focus();
                    return false;
                }
                else 
                    if (document.form.message.value == "" || document.form.message.value == document.form.message.defaultValue) {
                        alert("Please enter your comments.");
                        document.form.message.focus();
                        return false;
                    }					
   return submitForm();
}

function submitForm(){
	document.form.submit();
}


function disableForm(theform){
    if (document.all || document.getElementById) {
        for (i = 0; i < theform.length; i++) {
            var tempobj = theform.elements[i];
            if (tempobj.type.toLowerCase() == "submit") 
                tempobj.disabled = true;
        }
        setTimeout('alert("Your responses have been received. We appreciate your time and effort in completing the IRS Procurement Employee Suggestion Program Form.  Thank You.  Please select close window to exit.")', 1000);
        return true;
    }
}

function toggleDisplay(divId){
    var div = document.getElementById(divId);
    var div2 = document.getElementById('contentOurClub');
    div.style.display = (div.style.display == "block" ? "none" : "block");
    
    var state = div.style.display;
    if (state == "none") {
        div2.style.height = '1520px';
    }
    else {
        div2.style.height = '2220px';
    }
}

function toggleMainDisplay(divId){
    var div = document.getElementById(divId);
    var div2 = document.getElementById('testImage');
	var div3 = document.getElementById('greekDest');
    div.style.display = (div.style.display == "block" ? "none" : "block");
    
    var state = div.style.display;
    if (state == "none") {
		div2.style.position = 'relative';
	    div2.style.top = '-30px';
		div2.style.left = '-210px';						
    }
    else {
		div2.style.position = 'relative';
	    div2.style.top = '-30px';
		div2.style.left = '-232px';						
    }
}

function check_email(email_id){
    emailRegExp = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,4})$/;
    var err_mail = 'Email addres incorect!';
    if (emailRegExp.test(document.getElementById(email_id).value)) {
        return true;
    }
    else {
        return false;
    }
}
function autoResize(id){
	alert(id);
	var newheight;
	var newwidth;
	
	if (parent.document.getElementById) {
		newheight = document.getElementById(id).contentWindow.document.body.scrollHeight;
		alert('segaaaaaaaaaaaaoooo');
		alert(newheight);
		newwidth = document.getElementById(id).contentWindow.document.body.scrollWidth;
		alert(newwidth);
	}
	alert(newheight);
	alert(newwidth);
	
	document.getElementById(id).height = (newheight) + "px";
	document.getElementById(id).width = (newwidth) + "px";
}

function iFrameHeight() {
 if(document.getElementById && !(document.all)) {
   theFrame = document.getElementById('iframename');
   h = theFrame.contentDocument.body.scrollHeight;
   w = theFrame.contentDocument.body.scrollWidth;
   theFrame.style.height = h;
   theFrame.style.width = w;
 }else if(document.all) {
   h = window.frames.iframename.document.body.scrollHeight;
   w = window.frames.iframename.document.body.scrollWidth;
   document.all.iframename.style.height = h;
   document.all.iframename.style.width = w;
 }
}
function resizeIframe(iframeID) { 
if(self==parent) return false; /* Checks that page is in iframe. */ 
else if(document.getElementById&&document.all) /* Sniffs for IE5+.*/ 

var FramePageHeight = framePage.scrollHeight + 10; /* framePage 
is the ID of the framed page's BODY tag. The added 10 pixels prevent an 
unnecessary scrollbar. */ 

parent.document.getElementById(iframeID).style.height=FramePageHeight; 
/* "iframeID" is the ID of the inline frame in the parent page. */ 
} 
