function ksa(entered, alertbox)
{
with (entered)
{
apos=value.indexOf("@"); 
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
} 
function isblank(s)
{
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }
    return true;
}
function aymax(f)
{
    var msg;
    var empty_fields = "";
    var errors = "";


    for(var i = 0; i < f.length; i++) {
        var e = f.elements[i];
        if (((e.type == "text") || (e.type == "textarea")) && !e.optional) {

            if ((e.value == null) || (e.value == "") || isblank(e.value)) {
                empty_fields += "\n          " + e.name;
                continue;
            }

           if (e.numeric || (e.min != null) || (e.max != null)) { 
                var v = parseFloat(e.value);
                if (isNaN(v) || 
                    ((e.min != null) && (v < e.min)) || 
                    ((e.max != null) && (v > e.max))) {
                    errors += "- قيمة " + e.name + " يجب أن تكون رقما ..";
                    if (e.min != null) 
                        errors += " أكبر من " + e.min;
                    if (e.max != null && e.min != null) 
                        errors += " وأصغر من " + e.max;
                    else if (e.max != null)
                        errors += " أصغر من " + e.max;
                    errors += ".\n";
                }
            }
        }
    }
	
	       if (f.mail.value.indexOf("@") == -1 || f.mail.value.indexOf(".") == -1 || f.mail.value.length < 7 ) {
         errors += "من فضلك اكتب إيميلا صحيحا";
         f.mail.focus();
          }


       if (!empty_fields && !errors) return true;
    msg  = "______________________________________________________\n\n"
    msg += "لم يمكن إرسال الرسالة ..\n";
    msg += "يرجى كتابة جميع الحقول ..\n";
    msg += "______________________________________________________\n\n"
   
    msg += errors;
    alert(msg);
    return false;
}




<script type="text/javascript">


//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight;
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller


</script>

























function hide(elementtoh,alfa){
if(alfa){
document.getElementById(alfa).innerHTML="";
}
if(document.getElementById(elementtoh).style.display == 'block'){
document.getElementById(elementtoh).style.display = 'none';
}

}

function showit(div){
if(document.getElementById(div).style.display == 'none'){
document.getElementById(div).style.display = 'block';
if(this.commentform){
this.commentform.name.focus();
}else  if(this.newsform){
this.newsform.yourname.focus();
}
}
}
function dodiv(str,div,alfa){
document.getElementById(alfa).innerHTML=str;
showit(div);
}

function changesp(str){
document.getElementById('initial').innerHTML=str;
}
function getalfa(){
return document.getElementById('initial').innerHTML
}


function callajax(url,meth,parameters,div,alfa,func) {
var http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/html; charset=windows-1256');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e)
{}
}
}
if (http_request == null) {
alert("حدث خطأ ما أثناء الإرسال أو أن متصفحك لا يدعم الأجاكس , احصل على متصفح أفضل");
return;
}
var parms = "";
var result = "";
http_request.onreadystatechange =  function () {
var currentElement =document.getElementById(div+'callback');
if(currentElement){
currentElement.innerHTML="<img src=\"images/loading.gif\" border=\"0\">";
showit(div+'status');

}
if (http_request.readyState == 4 && http_request.status ==200){
result = http_request.responseText;
 if(currentElement){
hide(div+'status');
}
if(func){
dofunc(result,func,div,alfa);
}
if(div){
dodiv(result,div,alfa);
}

}

}
var parms;
http_request.open(meth, url , true);
if(meth=="POST"){
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=windows-1256");
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
parms = parameters;
}
http_request.send(parms);

}


function get(url,meth,obj,div,alfa,func) {
var my_data=document.getElementById('parameters').value.split(",");
var getstr = "";

for (p=0;p<my_data.length;p++){
if(my_data[p]){
getstr +=my_data[p]+ "=" + encodeURIComponent(document.getElementById(my_data[p]).value);
if(p<my_data.length-1){
getstr += "&";
}
}
}
callajax(url,meth,getstr,div,alfa,func);
}
function clearf(object,text){ if (object.value == text) {  object.value = "";  object.focus(); }} function setf(object,text){ if(object.value == "") {  object.value = text;  this.focus(); }}
