function updateProperty(id, el) {
    var propid = el.name.match(/prop(\d+)/)[1]
    var propval= el.value
    document.getElementById('add' + id).href = "/add/" + id + "/" + propid + "/" + propval + "/"
}

function switchLoginForm() {
    if (document.getElementById('login').style.display == 'none') {
        document.getElementById('login').style.display = 'block';
        document.getElementById('forgot').style.display = 'none';
    } else {
        document.getElementById('login').style.display = 'none';
        document.getElementById('forgot').style.display = 'block';
    }
}

function showCCOptions(t) {
    if (t) {
        document.getElementById('cc_options').style.display = 'block';
    } else {
        document.getElementById('cc_options').style.display = 'none';
    }
}

function swichvis(idName) {
    if (document.getElementById(idName).style.display == 'none') {
        document.getElementById(idName).style.display = 'block'
    } else {
        document.getElementById(idName).style.display = 'none'
    }
}
function bigPic(picname, title) {
    X = 50
    Y = 100
    W = 600
    H = 450
    var AutoClose = true
    if (parseInt(navigator.appVersion.charAt(0))>=4) {
        var isNN = (navigator.appName=="Netscape")?1:0
        var isIE = (navigator.appName.indexOf("Microsoft")!=-1)?1:0
    }
    var optNN = 'scrollbars=no,width='+W+',height='+H+',left='+X+',top='+Y
    var optIE = 'scrollbars=no,width='+W+',height='+H+',left='+X+',top='+Y

    var imageURL = 'http://www.israzer.co.il/images/' + picname
    var imageTitle = title
    if (isNN) {
        imgWin=window.open('about:blank','',optNN);
    }
    if (isIE) {
        imgWin=window.open('about:blank','',optIE);
    }
    with (imgWin.document) {
        writeln('<html><head><title>Loading...</title><style type="text/css">body{margin:0;padding:0;} img{display:block;}</style>')
        writeln('<sc'+'ript>')
        writeln('var isNN,isIE;')
        writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){')
        writeln('isNN=(navigator.appName=="Netscape")?1:0;')
        writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}')
        writeln('function reSizeToImage(){')
        writeln('if (isIE){')
        writeln('window.resizeTo(100,100);')
        writeln('width=100-(document.body.clientWidth-document.getElementById("bp").width);')
        writeln('height=100-(document.body.clientHeight-document.getElementById("bp").height);')
        writeln('window.resizeTo(width,height);}')
        writeln('if (isNN){')
        writeln('window.innerWidth=document.getElementById("bp").width;')
        writeln('window.innerHeight=document.getElementById("bp").height;}}')
        writeln('function doTitle(){document.title="'+imageTitle+'";}')
        writeln('</sc'+'ript>')
        if (!AutoClose) {
            writeln('</head><body scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
        } else {
            writeln('</head><body scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">')
        }
        writeln('<img id="bp" name="bp" src='+imageURL+' /></body></html>');
        close();
    }
}

function validateOrderForm() {
    if ($e('username').value == '') {
        alert('חובה למלא שם משתמש')
        return false
    }
    if ($e('password').value == '') {
        alert('חובה למלא סיסמא')
        return false
    }
    if ($e('password').value != $e('repassword').value) {
        alert('הסיסמא החוזרת שגויה')
        return false
    }
    if ($e('fname').value == '') {
        alert('חובה למלא שם פרטי')
        return false
    }
    if ($e('lname').value == '') {
        alert('חובה למלא שם משפחה')
        return false
    }
    if ($e('phonehome').value == '' && $e('cellphone').value == '') {
        alert('חובה למלא מספר טלפון אחד לפחות')
        return false
    }
    if ($e('city').value == '') {
        alert('חובה למלא עיר')
        return false
    }
    if ($e('street').value == '') {
        alert('חובה למלא שם רחוב')
        return false
    }
    if ($e('streetnum').value == '') {
        alert('חובה למלא מספר בית')
        return false
    }
    return true
}

$e = function(idName) {
    return document.getElementById(idName)
}