var sw = false;
function textCounter(field,countfield,maxlimit) {
    if (field.value.length > maxlimit){ // if too long...trim it!
        field.value = field.value.substring(0, maxlimit);
        alert("النص أكبر من الحد المسموح");
    }
    // otherwise, update 'characters left' counter
    else
        countfield.value = maxlimit - field.value.length;
}


function checkform() {
    with (document.partform) {
        if(frm_name.value=='' || frm_text.value=='') {
            alert('يرجى ملئ جميع الحقول');
            return false;
        }
        return true;
    }
}

function checkcomp() {
    with (document.compform) {
        if(com_text.value=='' || com_verify.value=='') {
            alert('يرجى ملئ جميع الحقول');
            return false;
        }
        return true;
    }
}


if (document.getElementById && document.createTextNode){canDOM=true}
function collapse(id){
	if (canDOM && document.getElementById(id)){
	    elm=document.getElementById(id);
        
	    if(elm.style.display=='none'||elm.style.display==''){
            elm.style.display= 'block';
        }
        else{
            elm.style.display= 'none';
        }
	}
}

function collapsem(id,plus){
	if (canDOM && document.getElementById(id)){
	    elm=document.getElementById(id);
        pelm=document.getElementById(plus);
        
	    if(elm.style.display=='none'||elm.style.display==''){
            elm.style.display= 'block';
            pelm.innerHTML="- ";
        }
        else{
            elm.style.display= 'none';
            pelm.innerHTML="+ ";
        }
	}
}

function show_rules(){
    window.open('rules.html','info9', 'width=420,height=110');
}