﻿//function that make the pic in the right size
function ImgSize(img,size)
{
    if(img.width <= img.height)
    {
        var Yachas = Number(img.width/img.height);
        alert(img.width + " " + img.height + " " +Yachas);
        img.height = size;
        img.width =  Math.floor(Yachas*size);
        
    }
    else if(img.width > img.height)
    {
        var Yachas = Number(img.height/img.width);
        img.width = size;
        img.height =  Math.floor(Yachas*size);       
    }
}

function AJAXread(URL){
    var url = URL;
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.open("GET",url,false);
    xmlhttp.send(null);
    return xmlhttp.responseText;
}

function search_Enter_Down(e) {
    var unicode = e.keyCode ? e.keyCode : e.charCode // Firefox event is not defined - fix
    //console.log(unicode);
    if (e.shiftKey != 1) { // Shift key not pressed
        if (unicode == 13) { // Enter
            search_click();
        }
    }
}

function search_click() {
    var search_val = document.getElementById('Search_Field').value;
    window.location = "search.aspx?search=" + search_val;
}

function set_search_value(str) {
    document.getElementById('Search_Field').value = str;
}
