
//-----------------------------------------------------------------------------
// formu göndermeden önce şekil koymak... (validation)
//-----------------------------------------------------------------------------
function checkGroupChecker(inputname){
        checkGroup = document.getElementsByName(inputname);
        for(cSayac=0; cSayac< checkGroup.length ; cSayac++){
                if(checkGroup[cSayac].checked){
                        return false;
                }
        }
        return true;
}

function submitForm(f){
	var attribute = "1!=1";
		for(i=0;i<f.elements.length;i++){
                input = f.elements[i];
				attribute = "1!=1";
				a = input.getAttribute('alert');
				a = a +' ';
				if(a!=' ' && a!=null+' '){
						if(attribute=="1!=1"){
								if(input.tagName=='SELECT'){
										attribute = "input.selectedIndex==0";
                                }
                                if(input.tagName=='TEXTAREA' || input.type=='text' || input.type=='password' || input.type=='file'){
										attribute = "input.value==''";
                                }

                                if(input.type=='checkbox' || input.type=='radio'){
										attribute = "checkGroupChecker('" + input.name +"')";
                                }
                        }
                        result = false;
                        eval('if('+attribute+' ){result=true;};');
                        //input.alert  \n\r replace edilecek
                        if(result==true){
                                alert(input.getAttribute('alert'));
                                input.focus();
                                input.style.backgroundColor = '#FFE1DD';
								input.style.color = '#000000';
                                return false;
                        }else{
							input.style.backgroundColor = '#FFFFFF';
							input.style.color = '#000000';
						}
                }
        }

        for(i=0;i<f.elements.length;i++){
                input = f.elements[i];
                if(input.className=='number') input.value = input.getValue();
                if(input.className=='date') input.value = input.getValue();
        }

        return true;
}

//-----------------------------------------------------------------------------
function paraBicim(deger,tur){
    var bicimli;
    bicimli = numberFormat(deger) + tur;
    //bicimli = deger + " TL";
    return bicimli;
}

//-----------------------------------------------------------------------------
function numberFormat(deger){
        var strDeger = deger + "";
        var retval="";
        if(strDeger.length > 3){
                retval = numberFormat(strDeger.substr(0,strDeger.length-3)) + "." + strDeger.substr(strDeger.length-3,3);
        }else{
                retval = strDeger;
        }
        return retval;
}


//-----------------------------------------------------------------------------
function winopen(href,w,h){
        openWin(href, w, h, true);
}

//-----------------------------------------------------------------------------
function openWin(url, win_width, win_height, center){
    if(center == true ){
        win_left = (screen.width  - win_width ) / 2;
        win_top  = (screen.height - win_height) / 2;
        prop = ",top=" + win_top + ",left=" + win_left + ",scrollbars=yes,menubar=no,resizable=yes,status=no,titlebar=no,toolbar=no";
    }else{
        prop = ",scrollbars=yes,menubar=no,resizable=yes,status=no,titlebar=no,toolbar=no";
    }

    openWinEx(url, win_width, win_height, prop);
}
//-----------------------------------------------------------------------------
function PopUpWin(url, win_width, win_height, center,winname){
    if(center == true ){
        win_left = (screen.width  - win_width ) / 2;
        win_top  = (screen.height - win_height) / 2;
        prop = ",top=" + win_top + ",left=" + win_left + ",scrollbars=yes,menubar=no,resizable=yes,status=yes,titlebar=no,toolbar=no";
    }else{
        prop = ",scrollbars=yes,menubar=no,resizable=yes,status=yes,titlebar=no,toolbar=no";
    }

    openWinEx(url, win_width, win_height, prop,winname);
}
//-----------------------------------------------------------------------------
function openWinEx(url, win_width, win_height, prop,winname){
    window.open(url, winname, "width=" + win_width + ", height=" + win_height + prop);
}

//-----------------------------------------------------------------------------
function openPopUp(url, width, height){
        var sFeatures = "center:yes;scroll:yes;status:no;help:no;dialogHeight:" + height + "px;dialogWidth:" + width + "px;";
        window.showModalDialog(url, "", sFeatures);
}// end of openPopUp

//-----------------------------------------------------------------------------
function isNumeric(s) {
    var numbers = "0123456789";
    var i;

    for (i = 0; i < s.length; i++){
        var c = s.charAt(i);
        if (numbers.indexOf(c) == -1){
            return false;
        }
    }
    return true;
}

function isEmailReg (s) {
    var emailexp = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]{2,4}$/
    if (emailexp.test(s)) return true; else return false;
}
