// JavaScript Document
var baseUrl="/uasweb/wp-content/themes/uas2.0";

function clearCart() {
	new Ajax.Updater('boxQuantity', baseUrl+'/rutinas/clearCart.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: {str: ''}
					}
					);	
}

function getRadioButtonSelectedValue(ctrl)
{
		alert(ctrl.lenght);
    for(i=0;i<ctrl.length;i++)
	
        if(ctrl[i].checked) return ctrl[i].value;
}

function espera(nombreDiv) {
	var temp='<p><center><img src="/imagenes/espera.gif"></center></p>';
	myDiv = document.getElementById(nombreDiv);
	myDiv.innerHTML = temp;
}

function buscaStd(divDestino, txtBox, opcion, usuario) {
	espera(divDestino);
	var seleccion=0;
	var texto='';
	if (opcion!=3) {
		texto=document.getElementById(txtBox).value;
	}
	if (opcion==2) {
		var seleccion="";
		for (i=0;i<document.form2.rsrc.length;i++) {
			if (document.form2.rsrc[i].checked==true) {
				seleccion=document.form2.rsrc[i].value;
			}
		}
			
	}
	
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/srchAjax.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: {str: encodeURIComponent(texto), opc: encodeURIComponent(opcion), sel: encodeURIComponent(seleccion), usr: encodeURIComponent(usuario)}
					}
					);
	//alert('Hola');
}



function buscaPag(divDestino, texto, opcion, pagina) {
	espera(divDestino);
	
	if (opcion==2) {
		var seleccion="";
		for (i=0;i<document.form2.rsrc.length;i++) {
			if (document.form2.rsrc[i].checked==true) {
				seleccion=document.form2.rsrc[i].value;
			}
		}
			
	}
	
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/srchAjax.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: {str: texto, opc: opcion, sel: seleccion, pag: pagina}
					}
					);
	
}

function agregaStd(divDestino, idPart) {
	espera(divDestino);
	
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/cartAjax.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: {idP: idPart, cant: '1', opc: 'add'}
					}
					);
}

function borraStd(divDestino, idPart) {
	espera(divDestino);
	
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/cartAjax.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: {idP: idPart, cant: '1', opc: 'del'}
					}
					);
}

function cambiaStd(divDestino, idPart, cantNew) {
	espera(divDestino);
	
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/cartAjax.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: {idP: idPart, cant: cantNew, opc: 'upd'}
					}
					);
}

function checkStd(divDestino) {
	espera(divDestino);
	
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/chckAjax.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: { opc: 'shw'}
					}
					);	
}


function checkoutPaso1(divDestino, reference, info) {
	espera(divDestino);
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/submitRequest.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: {opc1: '1', txtRef: reference, txtInfo: info, grp: '1'}
					}
					);
}



function borraDiv(divDestino) {
	myDiv = document.getElementById(divDestino);
	myDiv.innerHTML = "";
}

function buscaMulti1(divDestino, multiSrc, usr) {
	espera(divDestino);
	var box1t=document.getElementById(multiSrc).value;	
	
	
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/srchAjaxMulti1.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: {txt1: box1t, usr: usr}
					}
					);
	
}

function buscaMulti(divDestino, box1, box2, box3, box4, box5, box6, box7, box8, box9, box10, usr) {
	espera(divDestino);
	var box1t=document.getElementById(box1).value;	
	var box2t=document.getElementById(box2).value;	
	var box3t=document.getElementById(box3).value;	
	var box4t=document.getElementById(box4).value;	
	var box5t=document.getElementById(box5).value;	
	var box6t=document.getElementById(box6).value;	
	var box7t=document.getElementById(box7).value;	
	var box8t=document.getElementById(box8).value;	
	var box9t=document.getElementById(box9).value;	
	var box10t=document.getElementById(box10).value;	
	
	
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/srchAjaxMulti.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: {txt1: box1t, txt2: box2t, txt3: box3t, txt4: box4t, txt5: box5t, txt6: box6t, txt7: box7t, txt8: box8t, txt9: box9t, txt10: box10t, usr: usr}
					}
					);
	
}

function buscaPagMulti1(divDestino, pagina, box1, usr) {
	espera(divDestino);
	
	var box1t=document.getElementById(box1).value;	
	
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/srchAjaxMulti1.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: {pag: pagina, txt1: box1t, usr: usr}
					}
					);
	
}


function buscaPagMulti(divDestino, pagina, box1, box2, box3, box4, box5, box6, box7, box8, box9, box10) {
	espera(divDestino);
	
	var box1t=document.getElementById(box1).value;	
	var box2t=document.getElementById(box2).value;	
	var box3t=document.getElementById(box3).value;	
	var box4t=document.getElementById(box4).value;	
	var box5t=document.getElementById(box5).value;	
	var box6t=document.getElementById(box6).value;	
	var box7t=document.getElementById(box7).value;	
	var box8t=document.getElementById(box8).value;	
	var box9t=document.getElementById(box9).value;	
	var box10t=document.getElementById(box10).value;	
	
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/srchAjaxMulti.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: {pag: pagina, txt1: box1t, txt2: box2t, txt3: box3t, txt4: box4t, txt5: box5t, txt6: box6t, txt7: box7t, txt8: box8t, txt9: box9t, txt10: box10t}
					}
					);
	
}


function listaClearance(divDestino, pagina, letras) {
	espera(divDestino);
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/listaClearance.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: {pag: pagina, grupo: letras}
					}
					);
}

function listaClearanceMan(divDestino, pagina, manufacturer, usuario) {
	espera(divDestino);
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/listaClearanceManufacturer.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: {pag: pagina, man: manufacturer, usr: encodeURIComponent(usuario)}
					}
					);
}

function agregaClearance(divDestino, idPart) {
	espera(divDestino);
	
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/cartAjaxClearance.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: {idP: idPart, cant: '1', opc: 'add'}
					}
					);
}

function borraClearance(divDestino, idPart) {
	espera(divDestino);
	
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/cartAjaxClearance.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: {idP: idPart, cant: '1', opc: 'del'}
					}
					);
}

function cambiaClearance(divDestino, idPart, cantNew) {
	espera(divDestino);
	
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/cartAjaxClearance.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: {idP: idPart, cant: cantNew, opc: 'upd'}
					}
					);
}

function checkClearance(divDestino) {
	espera(divDestino);
	
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/chckAjaxClearance.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: { opc: 'shw'}
					}
					);	
}

function checkoutClearancePaso1(divDestino, reference, info) {
	espera(divDestino);
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/submitRequest.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: {opc1: '1', txtRef: reference, txtInfo: info, grp: '2'}
					}
					);
}

function checkoutPaso2(divDestino, grupo, txtCompany, txtAddress, txtCity, txtCountry, txtState, txtPobox, txtPhone, txtFax, txtEmail, txtContact) {
	espera(divDestino);
	
	/*
	var company=document.getElementById(txtCompany).value;
	var address=document.getElementById(txtAddress).value;
	var city=document.getElementById(txtCity).value;
	var country=document.getElementById(txtCountry).value;
	var state=document.getElementById(txtState).value;
	var pobox=document.getElementById(txtPobox).value;
	var phone=document.getElementById(txtPhone).value;
	var fax=document.getElementById(txtFax).value;
	var email=document.getElementById(txtEmail).value;
	var contact=document.getElementById(txtContact).value;
	*/
	
	
	new Ajax.Updater(divDestino, baseUrl+'/rutinas/submitEmail.php', {
						evalScripts: true,
						encoding: 'UTF-8',
						method: 'get',
						parameters: {grp: grupo, company: txtCompany, address: txtAddress, city: txtCity, country: txtCountry, state: txtState, pobox: txtPobox, phone: txtPhone, fax: txtFax, email: txtEmail, contact: txtContact}
					}
					);
}


function abrirVentana(direccion, pantallacompleta, herramientas, direcciones, estado, barramenu, barrascroll, cambiatamano, ancho, alto, izquierda, arriba, sustituir){
     var opciones = "fullscreen=" + pantallacompleta +
                 ",toolbar=" + herramientas +
                 ",location=" + direcciones +
                 ",status=" + estado +
                 ",menubar=" + barramenu +
                 ",scrollbars=" + barrascroll +
                 ",resizable=" + cambiatamano +
                 ",width=" + ancho +
                 ",height=" + alto +
                 ",left=" + izquierda +
                 ",top=" + arriba;
     var ventana = window.open(direccion,"venta",opciones,sustituir);

}                     

