
function sndReqDd(mode, sid) {
					
r = Math.round((Math.random() * (10000000 - 1)));
http.open("get", "/aj/ddmenu" + "/" + mode + '-' + sid + "/?r=" + r);
if(mode=="all")
    {   http.onreadystatechange = handleResponseAll;}
if(mode=="cat")
    {   http.onreadystatechange = handleResponseCat;}
http.send(null);
}
								    
function handleResponseCat() {
if(http.readyState == 4){
    response = http.responseText;
    document.getElementById("dd_vendor").innerHTML = response;
    }
}
	
function handleResponseAll() {
if(http.readyState == 4){
    response = http.responseText;
    document.getElementById("dd_card").innerHTML = response;
    }
}

	
function categorySearch() {
if (document.ddform.elements["category"].options[document.ddform.elements["category"].selectedIndex].value != 'NONE')
    {
    id=document.ddform.elements["category"].options[document.ddform.elements["category"].selectedIndex].value;
    if(id==193 || id==195 || id==14 || id==13 || id==196 || id==548 || id==898){
        document.getElementById("dd_vendor").innerHTML = '<select></select>';
        document.getElementById("dd_card").innerHTML = '<select class="last"></select>';
    }else{
        sndReqDd('cat', document.ddform.elements["category"].options[document.ddform.elements["category"].selectedIndex].value);
        document.getElementById("dd_card").innerHTML = '<select class="last"></select>';
    }
    }
else
    {
    document.getElementById("dd_vendor").innerHTML = '<select></select>';
    document.getElementById("dd_card").innerHTML = '<select class="last"></select>';
    document.getElementById("dd_link").innerHTML = '';
    }
    
}
																	    
function cardSearch() {
    if ((document.ddform.elements["category"].options[document.ddform.elements["category"].selectedIndex].value != 'NONE')
    & (document.ddform.elements["vendor"].options[document.ddform.elements["vendor"].selectedIndex].value != 'NONE')) {
	query = document.ddform.elements["category"].options[document.ddform.elements["category"].selectedIndex].value 
	+ '-' + document.ddform.elements["vendor"].options[document.ddform.elements["vendor"].selectedIndex].value;
	sndReqDd('all',query);
    } else {
	document.getElementById("dd_card").innerHTML = '<select></select>';
    }
}


function goToProduct() {
    if (document.ddform.elements["card"] && document.ddform.elements["card"].options[document.ddform.elements["card"].selectedIndex].value != 'NONE') {
	go = document.ddform.elements["card"].options[document.ddform.elements["card"].selectedIndex].value;
	window.location = "/tx/" + go;
	return false;
    }
	
	if (document.ddform.elements["category"].options[document.ddform.elements["category"].selectedIndex].value != 'NONE') {
	go = document.ddform.elements["category"].options[document.ddform.elements["category"].selectedIndex].value;
	window.location = "/gd/" + go;
	return false;
    }
	
	
	return false;
}

 function login_on() {
 document.getElementById('login-on').style.display='block'
 }

 function login_off() {
 document.getElementById('login-on').style.display='none'
 }