var ajaxreq = false, ajaxCallback;
//###################################################################
//GLOBAL AJAX REQUEST CONSTRUCTOR
//###################################################################
function ajaxRequest(filename) {
try {
ajaxreq = new XMLHttpRequest();
} catch (error) {
try {
ajaxreq = new ActiveXObject("Microsoft.XMLHTTP");
} catch (error) {
return false;
}
}
ajaxreq.open("GET",filename,true);
ajaxreq.onreadystatechange = ajaxResponse;
ajaxreq.send(null);
}
//###################################################################
//GLOBAL AJAX RESPONSE CONSTRUCTOR
//###################################################################
function ajaxResponse() {
if (ajaxreq.readyState != 4) return;
if (ajaxreq.status == 200) {
if (ajaxCallback) ajaxCallback();
} else alert("Request failed: " + ajaxreq.statusText);
return true;
}
//###################################################################
//SCROLL TO LAST POSITION ON PAGE
//###################################################################
function js_setScroll() {
var point = document.getElementById('scroll_point').value;
if (point > 0) {
document.body.scrollTop = point;
}
}
//###################################################################
//CHECK AVAILABILITY OF TRACK WORD
//###################################################################
function js_checkTrackWord() {
var word = document.getElementById('products_word').value;
var pid = document.getElementById('products_id').value;
if (pid) {
var products_id = pid;
} else {
var products_id = 0;
}
if (word && word.length > 0) {
//START LOADING GRAPHIC
var graphic = document.getElementById('loading_graphic');
if (graphic) {
graphic.style.width = "16px";
graphic.innerHTML = '';
graphic.style.background = "url('/images/css/loading.gif')";
}
var filename = "index.php?group=vendor&class=ajax&task=check_track_word&products_id=" + pid + "&products_word=" + word;
ajaxCallback = js_trackWordInfo;
ajaxRequest(filename);
} else {
js_validateForm(100);
}
}
function js_trackWordInfo() {
var response = ajaxreq.responseXML.getElementsByTagName("response")[0].childNodes[0].nodeValue;
//STOP LOADING GRAPHIC
var graphic = document.getElementById('loading_graphic');
if (graphic) graphic.style.background = "#ffffff";
if (response == 1) {
var message = document.getElementById('loading_graphic');
document.getElementById('products_word').style.background = 'yellow';
if (graphic) graphic.style.width = "auto";
if (graphic) message.innerHTML = "That word is already taken";
} else {
js_validateForm(100);
}
}
//###################################################################
//NAME: js_uploadMP3File(form)
//###################################################################
function js_uploadMP3File(form)
{
var i = js_validateForm(form);
if (!i) {
var indicator = document.getElementById('loading_file_text');
if (indicator) indicator.style.display = 'block';
}
}
//###################################################################
//CREATE VIDEO PLAYER
//###################################################################
function js_flvPlayer(vendors_id,size) {
if (size == 1) {
var w = 380;
var h = 285;
var logo = '/images/shops/no_product_image_tr.png';
} else {
var w = 186;
var h = 155;
var logo = '/images/shops/no_product_image_tr_s.png';
}
var location = 'video' + vendors_id;
var so = new SWFObject("/mplayer/mediaplayer.swf","mediaplayer",w,h,"8");
so.addVariable("height",h);
so.addVariable("width",w);
so.addVariable("backcolor","0xFFFFFF");
so.addVariable("screencolor","0xFFFFFF");
so.addVariable("logo",logo);
so.addVariable("frontcolor","0x990000");
so.addVariable("file","videos/video" + vendors_id + ".flv");
so.addVariable("image","/mplayer/videos/video" + vendors_id + ".png?" + (new Date()).getTime());
so.write(location);
return;
}
//###################################################################
//DISPLAY PRE-RELEASE DATETIME FORM IN ADD PRODUCT
//###################################################################
function js_displayPrData() {
var prRadio = document.getElementById('pr_radio');
var prData = document.getElementById('pr_data');
if (prRadio.checked) {
prData.style.display = 'block';
} else {
prData.style.display = 'none';
}
}
//###################################################################
//CHANGE PRODUCT FORM BASED ON TYPE
//###################################################################
function js_typeFormUpdate() {
var cc_cost = document.getElementById('cc_cost').value;
var selectedTypeIndex = document.getElementById("products_type").selectedIndex;
var selectedType = document.getElementById("products_type").options[selectedTypeIndex].value;
var edit_product = document.edit_product;
if (selectedType == 1) {
if (!edit_product) document.getElementById('products_stock').value = "1";
document.getElementById('products_delivery_weight_block').style.display = "block";
if (!edit_product) document.getElementById('products_price').value = "0.00";
document.getElementById('products_price_block').style.display = "block";
} else if (selectedType == 2) {
if (!edit_product) document.getElementById('products_stock').value = "10000";
document.getElementById('products_delivery_weight_block').style.display = "none";
document.getElementById('products_price').value = cc_cost;
document.getElementById('products_price_block').style.display = "none";
} else if (selectedType == 4) {
if (!edit_product) document.getElementById('products_stock').value = "20";
document.getElementById('products_delivery_weight_block').style.display = "none";
if (!edit_product) document.getElementById('products_price').value = "0.00";
document.getElementById('products_price_block').style.display = "block";
}
}
//###################################################################
//VALIDATE REQUIRED FORM FIELDS
//###################################################################
function js_validateForm(form) {
var req=document.getElementById('required' + form);
var match=document.getElementById('match' + form);
if (req) {
var reqfields=document.getElementById('required' + form).value.split(',');
}
if (match) {
var matchfields=document.getElementById('match' + form).value.split(',');
}
if (reqfields) {
for (var i=0;i