function printpage(rooturl, completeurl) {
    var printurl=rooturl+"alaweb_print.php";
    window.open(printurl, "Printpage", "width=1000,height=560,top=600,scrollbars=yes,resizable=yes");
}
function decode4javascript(htmlcode) {
    htmlcode=htmlcode.replace(/%&/g,'"');
    htmlcode=htmlcode.replace(/@#/g,"'");
    return htmlcode;
}
function popup(rooturl,type, value) {
    var href=rooturl+'alaweb_popup.php?'+type+"="+value;
    if(type=="f") {
        var title="Upload";
        var pop=window.open(href, title, "width=400,height=200,scrollbars=yes,resizable=yes,top=200,left=400");
        pop.focus();
    } else if(type=="i") {
        var title="Upload";
        var pop=window.open(href, title, "width=400,height=200,scrollbars=yes,resizable=yes,top=200,left=400");
        pop.focus();            
    } else {
        var title="Text";
        var pop=window.open(href, title, "width=400,height=200,scrollbars=yes,resizable=yes,top=200,left=400");
        pop.focus();
    }
}
function alacmspopup(rooturl,type, value) {
    var href=rooturl+'alacms/alacms_popup.php?'+type+"="+value;
    if(type=="f") {
        var title="Upload";
        var pop=window.open(href, title, "width=400,height=200,scrollbars=yes,resizable=yes,top=200,left=400");
        pop.focus();
    } else if(type=="i") {
        var title="Upload";
        var pop=window.open(href, title, "width=400,height=200,scrollbars=yes,resizable=yes,top=200,left=400");
        pop.focus();            
    } else {
        var title="Text";
        var pop=window.open(href, title, "width=400,height=200,scrollbars=yes,resizable=yes,top=200,left=400");
        pop.focus();
    }
}
function change_variablevalue(form,variablename,gotoscreen,defaultscreen,savescreen) {
    var alavariable=document.forms[form].elements[variablename];
    if(alavariable.value==defaultscreen) {
        alavariable.value=gotoscreen;
        document.forms[form].action = savescreen;
        document.forms[form].submit();
    } else {
        alavariable.value+='@'+gotoscreen;
        document.forms[form].action = savescreen;
        document.forms[form].submit();
    }
}
function selectdropdownvalue(variable, url) {
    // grab index number of the selected option
    var dpobject=document.getElementById(variable);
    selInd = dpobject.selectedIndex; 
    // get value of the selected option
    value = dpobject.options[selInd].value;
    if(value=="NULL") {
    	window.location.href=url;
    } else if(value=="") {
        window.location.href=url+"&"+variable+"=empty";
    } else {
	    window.location.href=url+"&"+variable+"="+value;
	}    
}
function selectcheckboxvalue(variable, url) {
    // grab index number of the selected option
    var cbobject=document.getElementById(variable);
    if(cbobject.checked==1) {
    	window.location.href=url+"&"+variable+"="+1;
    } else {
	    window.location.href=url+"&"+variable+"="+0;
    }
}
function formsubmit(formname) {
    document.forms[formname].submit();
}
