/* $Id: general.js,v 1.5 2005/03/29 22:59:11 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2005 osCommerce Released under the GNU General Public License function clickIE4(){ if (event.button==2){ //alert(message); return false; } } function clickNS4(e){ if (document.layers||document.getElementById&&!document.all){ if (e.which==2||e.which==3){ //alert(message); return false; } } } if (document.layers){ document.captureEvents(Event.MOUSEDOWN); document.onmousedown=clickNS4; } else if (document.all&&!document.getElementById){ document.onmousedown=clickIE4; } document.oncontextmenu=new Function("return false") */ var xmlhttp; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); // Firefox, Opera, Konqueror, Safari, ... } else if (window.ActiveXObject) { xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); // Internet Explorer } else { alert('JavaScript : Your broswer does not allow XML HTTP Request Objects ...'); // Old browser } var ajax_urls = new Array(); var ajax_busy = 0; function do_ajax() { if(ajax_urls.length){ data = ajax_urls.shift(); ajax_busy = 1; xmlhttp.open("GET", data[0]); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { eval(data[1]); ajax_busy = 0; do_ajax(); } } xmlhttp.send(null); } } function loadFragment(fragment_url,action) { ajax_urls.push(new Array(fragment_url,action)); if(ajax_busy)return; do_ajax(); } function loadFragmentInTo(fragment_url, elementas) { loadFragment(fragment_url,'elementas.innerHTML = xmlhttp.responseText;'); } function loadFragmentInToElementVal(fragment_url, element_id) { loadFragment(fragment_url,'document.getElementById("'+element_id+'").value = xmlhttp.responseText;'); } function loadFragmentInToElement(fragment_url, element_id) { loadFragment(fragment_url,'document.getElementById("'+element_id+'").innerHTML = xmlhttp.responseText;'); } function MakeArray(){ var items=new Array; j=MakeArray.arguments.length; if(MakeArray.arguments[j-1]==null)j--; for(i=0;i 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + value + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function submit_this(oForm) { if(check_attribs(document.forms[oForm])) document.forms[oForm].submit(); } function submit_form(oForm) { if(check_form()) document.forms[oForm].submit(); } function popupWindow(url) { window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150') } function updateDatePullDownMenu(objForm, fieldName) { var pdmDays = fieldName + "_days"; var pdmMonths = fieldName + "_months"; var pdmYears = fieldName + "_years"; time = new Date(objForm[pdmYears].options[objForm[pdmYears].selectedIndex].text, objForm[pdmMonths].options[objForm[pdmMonths].selectedIndex].value, 1); time = new Date(time - 86400000); var selectedDay = objForm[pdmDays].options[objForm[pdmDays].selectedIndex].text; var daysInMonth = time.getDate(); for (var i=0; i=_images) { i=0; } preview.src = 'thumb.php?img='+_image[i][0]+'&w='+_image[i][1]+'&h='+_image[i][2]; preview.width = _image[i][1]; preview.height = _image[i][2]; i_url.href = 'image.php?s='+_image[i][0]; i_url2.href = 'image.php?s='+_image[i][0]; _curimage=i; }//reloadImage function check_attribs(oForm) { alert_it = false for(var i = 0; i < oForm.elements.length; i++) { if(oForm.elements[i].value=="") alert_it = true; } if(alert_it) { alert(TEXT_PRODUCT_OPTIONS_SELECT); return false; } return true; }//check_attribs function check_options(model,op_id,current) { var row = document.getElementById("sel"+op_id); if(null == row){ // alert(model); if(undefined == _model[model]) return false; return _model[model][1] != -1; } var sel_id = row.getAttribute( "sel" ).toString(); var sel = document.getElementById("s"+sel_id); var ret = false; if(op_id > current) { if(undefined != _opt[sel_id]) { // alert(_opt[sel_id]); for (var i=1,j=1;i < _opt[sel_id].length-1;i++) { var cur_model = _opt[sel_id][i-1][2]; // alert(model+cur_model); var r = check_options(model+cur_model,op_id+1,current); sel.options[j] = null; if(r){ // alert(sel_id +' '+_opt[sel_id][i-1][0]+' '+_opt[sel_id][i-1][1]); sel.options[j] = new Option(_opt[sel_id][i-1][1],_opt[sel_id][i-1][0]); sel.options[j].setAttribute( "model" , _opt[sel_id][i-1][2]); j++; } ret = ret | r; } } } else { var cur_model = sel.options[sel.selectedIndex].getAttribute( "model" ).toString(); // alert(model+cur_model); return check_options(model+cur_model,op_id+1,current); } return ret; } // check_options function change_price(selector) { document.getElementById('onstock').innerHTML = ""; document.getElementById('receive_on').innerHTML = ""; p_model = selector.options[ selector.selectedIndex ].getAttribute( "model" ).toString(); j = selector.getAttribute( "num" ).toString()*1; new_model = nr_model; // alert(selector.selectedIndex); if(selector.selectedIndex != 0) { j++; sel = document.getElementById("sel"+j); if(null != sel) { sel.style.visibility = "visible"; check_options(nr_model,1,j-1); } } else { for (var i=j+1;i<6;i++) { sel = document.getElementById("sel"+i); if(null == sel) break; sel.style.visibility = "hidden"; } } for (var i=1;i<6;i++) { sel = document.getElementById("sel"+i); if(null == sel) break; sel_id = sel.getAttribute( "sel" ).toString(); var select = document.getElementById("s"+sel_id); if(select.selectedIndex) { new_model = new_model + select.options[ select.selectedIndex ].getAttribute( "model" ).toString(); } } if(selector.selectedIndex != 0) { for(i=0;i<_images;i++){ _img = _image[i][0].split('/'); _img = _img[_img.length-1].split('.'); if(new_model.indexOf(_img[0])!=-1) { reloadImage(i); break; } } } if(undefined != _model[new_model]) { if(_model[new_model][1]>0) { set_html('onstock',TEXT_PRODUCT_ON_STOCK); } set_html('receive_on',_model[new_model][0]); } if (undefined != _model[new_model]) { if(_model[new_model][5] != "") { // spec price set_html('old_price',_model[new_model][2]); set_html('spec_price',_model[new_model][5]); set_html('price',""); } else if(_model[new_model][4] != "") { //pricelist set_html('spec_price',""); set_html('price',_model[new_model][4]); set_html('old_price',_model[new_model][2]); } else { //regular price set_html('price',_model[new_model][2]); if(_model[new_model][4] != "0")set_html('spec_price',""); if(_model[new_model][5] != "0")set_html('old_price',""); } } else { set_html('price',(_price=="")?_old_price:_price); set_html('spec_price',""); if(_old_price != "")set_html('old_price',_old_price); } } // change_price function check_form(form, psw_len, err1, err2) { alert(form); for(i=0;i