var sFolder = "http://www.big927fm.com/xml/"; var sURLGetList = sFolder + "get_list.php?"; var requestsQueue = new Array(); var arrInitialValuesOfAsyncFields = new Array(); var updatedFields = new Array(); var sPostName; var sPostValue; var bPostAction; /* * updateList - function updates options list in drop-down box */ function UpdateListCommon(dataType, targetField, filterFlag, iID, sCustomTargetField1, sCustomTargetField2, sUnit) { if (document.getElementById(targetField)) {//if target exists switch (dataType) { case "getRJsList" : ClearSelection(targetField); selection = document.getElementById(targetField); optionObject = new Option('Loading...', 'null', false, false); selection.options[selection.length] = optionObject; var sURLRequest = "dataType="+dataType+"&"+filterFlag+"="+iID; addRequestToQueue(sURLRequest, dataType, targetField); break; case "ReloadCategories": if(iID > '0') { document.getElementById('fieldCadAdd').style.display = 'block'; document.getElementById('fieldsCatDel').style.display = 'block'; } else { document.getElementById('fieldCadAdd').style.display = 'none'; document.getElementById('fieldsCatDel').style.display = 'none'; } ClearSelection(targetField); selection = document.getElementById(targetField); optionObject = new Option('Loading...', 'null', false, false); selection.options[selection.length] = optionObject; var sURLRequest = "dataType="+dataType+"&"+filterFlag+"="+iID; addRequestToQueue(sURLRequest, dataType, targetField); break; case "ReloadSubCategories": if(iID > '0') { document.getElementById('fieldSubCadAdd').style.display = 'block'; document.getElementById('fieldsSubCatDel').style.display = 'block'; }else { document.getElementById('fieldSubCadAdd').style.display = 'none'; document.getElementById('fieldsSubCatDel').style.display = 'none'; } ClearSelection(targetField); selection = document.getElementById(targetField); if (selection) { optionObject = new Option('Loading...', 'null', false, false); selection.options[selection.length] = optionObject; } /*if (oElement = document.getElementById(targetField)) { oElement.style.display = 'none'; }*/ var sURLRequest = "dataType="+dataType+"&"+filterFlag+"="+iID; addRequestToQueue(sURLRequest, dataType, targetField, '', '', ''); break; case "MusicSubCategories": document.getElementById('subid').style.display = 'block'; document.getElementById('selsubcategoriesbox').style.display = 'block'; ClearSelection(targetField); selection = document.getElementById(targetField); if (selection) { optionObject = new Option('Loading...', 'null', false, false); selection.options[selection.length] = optionObject; } /*if (oElement = document.getElementById(targetField)) { oElement.style.display = 'none'; }*/ var sURLRequest = "dataType="+dataType+"&selbox="+iID; addRequestToQueue(sURLRequest, dataType, targetField, '', '', ''); break; /* this code is added by kapil */ case "VideoSubCategories": /* if(iID > '0') { document.getElementById('fieldSubCadAdd').style.display = 'block'; document.getElementById('fieldsSubCatDel').style.display = 'block'; }else { document.getElementById('fieldSubCadAdd').style.display = 'none'; document.getElementById('fieldsSubCatDel').style.display = 'none'; }*/ document.getElementById('subid').style.display = 'block'; document.getElementById('selsubcategoriesbox').style.display = 'block'; ClearSelection(targetField); selection = document.getElementById(targetField); if (selection) { optionObject = new Option('Loading...', 'null', false, false); selection.options[selection.length] = optionObject; } /*if (oElement = document.getElementById(targetField)) { oElement.style.display = 'none'; }*/ var sURLRequest = "dataType="+dataType+"&selbox="+iID; addRequestToQueue(sURLRequest, dataType, targetField, '', '', ''); break; /* this code is added by kapil */ /*----*/ case "ReloadClassifieds": ClearSelection(targetField); selection = document.getElementById(targetField); optionObject = new Option('Loading...', 'null', false, false); selection.options[selection.length] = optionObject; var sURLRequest = "dataType="+dataType+"&"+filterFlag+"="+iID; addRequestToQueue(sURLRequest, dataType, targetField); break; case "ReloadSubTree": selection = document.getElementById(targetField); if (selection.innerHTML == '') { oPicSelection = document.getElementById("tree_action_img_" + iID); oPicSelection.src = "images/minus.gif"; var bReloadTree = true; var sURLRequest = "dataType="+dataType+"&"+filterFlag+"="+iID; addRequestToQueue(sURLRequest, dataType, targetField, '', '', '', bReloadTree); } else { oPicSelection = document.getElementById("tree_action_img_" + iID); oPicSelection.src = "images/plus.gif"; selection.innerHTML = ''; } break; case "ReloadClassifiedsAndCustomsFields": ClearSelection(targetField); selection = document.getElementById(targetField); if (selection) { optionObject = new Option('Loading...', 'null', false, false); selection.options[selection.length] = optionObject; } var bAdminMan = document.getElementById('admin_managing'); if (bAdminMan) { //document.getElementById('customRow1').style.display = 'none'; //document.getElementById('customRow2').style.display = 'none'; document.getElementById('CustomName1').value=""; document.getElementById('CustomName2').value=""; document.getElementById('CustomAction1').value="-1"; document.getElementById('CustomAction2').value="-1"; } if (oElement = document.getElementById(targetField)) { oElement.style.display = 'none'; } if (oElement = getCustomActionField(sCustomTargetField1)) { oElement.style.display = 'none'; } if (oElement = getCustomActionField(sCustomTargetField2)) { oElement.style.display = 'none'; } var sURLRequest = "dataType="+dataType+"&"+filterFlag+"="+iID; addRequestToQueue(sURLRequest, dataType, targetField, sCustomTargetField1, sCustomTargetField2, sUnit); break; case "ReloadOnlyCustomsFields": if (oElement = getCustomActionField(sCustomTargetField1)) { oElement.style.display = 'none'; } if (oElement = getCustomActionField(sCustomTargetField2)) { oElement.style.display = 'none'; } var sURLRequest = "dataType="+dataType+"&"+filterFlag+"="+iID; addRequestToQueue(sURLRequest, dataType, '', sCustomTargetField1, sCustomTargetField2); break; } } } function addRequestToQueue(sURLRequest, sXmlNodeName, toField, sCustomTargetField1, sCustomTargetField2, sUnit, bReloadTree) { requestsQueue[requestsQueue.length] = new QueueItem(sURLGetList+sURLRequest, sXmlNodeName, toField, '', '', '', ''); if (requestsQueue.length == 1) doSendRequest(); } function QueueItem(url, sXmlNodeName, toField, sCustomTargetField1, sCustomTargetField2, sUnit, bReloadTree) { this.url=url; this.sXmlNodeName=sXmlNodeName; this.toField=toField; //this.bReloadTree=bReloadTree; //this.sCustomTargetField1 = sCustomTargetField1; //this.sCustomTargetField2 = sCustomTargetField2; this.sUnit = sUnit; } function doSendRequest() { globalObjXmlHttpRequest = createXmlHttpObject(); if ( globalObjXmlHttpRequest ) { globalObjXmlHttpRequest.onreadystatechange = RecieveData; globalObjXmlHttpRequest.open("GET", requestsQueue[0].url); globalObjXmlHttpRequest.send(null); } } function createXmlHttpObject() { var objXmlHttp = false; if ( window.XMLHttpRequest ) objXmlHttp = new XMLHttpRequest(); else if ( window.ActiveXObject ) objXmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); return objXmlHttp; } function RecieveData() { if(globalObjXmlHttpRequest.readyState == 4) { // if( requestsQueue[0] ) // { // alert( requestsQueue[0].url ); //window.open( requestsQueue[0].url ); // } // Dequeue request and run the handler if ((requestData = requestsQueue.shift()) == null) throw new Error('Internal error: queue is empty'); if (globalObjXmlHttpRequest.status == 200) { if (requestData.toField) { ClearSelection(requestData.toField, requestData.bReloadTree); } fillSelectionWithXmlData(requestData.sXmlNodeName, requestData.toField, globalObjXmlHttpRequest.responseXML, requestData.sCustomTargetField1, requestData.sCustomTargetField2, requestData.sUnit, requestData.bReloadTree); } if (requestsQueue.length > 0) doSendRequest(); selection = document.getElementById(requestData.toField); if (arrInitialValuesOfAsyncFields[requestData.toField] != undefined && arrInitialValuesOfAsyncFields[requestData.toField] != '') selection.value = arrInitialValuesOfAsyncFields[requestData.toField]; arrInitialValuesOfAsyncFields[requestData.toField]=null; selection = document.getElementById(requestData.toField); if (selection) { if (typeof(selection.onchange) == 'function') selection.onchange(); // Perform chain action } } } function ClearSelection(selectionID, bReloadTree) { var selection = document.getElementById(selectionID); if (bReloadTree) { selection.innerHTML = ''; } else { for (var i = selection.options.length - 1; i >= 0; i--) { selection.options[i] = null; } } } function fillSelectionWithXmlData(targetXmlTagName, selectionID, xmlNode, sCustomTargetField1, sCustomTargetField2, sUnit, bReloadTree) { var selection = document.getElementById(selectionID); var options = xmlNode.getElementsByTagName(targetXmlTagName); var strt=''; var bAdminMan = document.getElementById('admin_managing'); if (bAdminMan==null) bAdminMan = false; for (var optionIndex = 0; optionIndex <= options.length - 1; optionIndex++) { var optionData = options[optionIndex].childNodes; var optionID = ''; var optionValue = ''; var optionCnt = ''; var custFieldName1 = ''; var custFieldName2 = ''; var customAction1 = ''; var customAction2 = ''; var sUnitValue = ''; for (var propertyIndex = 0; propertyIndex <= optionData.length - 1; propertyIndex++) { if (optionData[propertyIndex].nodeType == 1 && optionData[propertyIndex].nodeName == 'ID') optionID = getNodeText(optionData[propertyIndex]); if (optionData[propertyIndex].nodeType == 1 && optionData[propertyIndex].nodeName == 'Name') optionValue = getNodeText(optionData[propertyIndex]); if (optionData[propertyIndex].nodeType == 1 && optionData[propertyIndex].nodeName == 'Count') optionCnt = getNodeText(optionData[propertyIndex]); if (optionData[propertyIndex].nodeType == 1 && optionData[propertyIndex].nodeName == 'CustomFieldName1') custFieldName1 = getNodeText(optionData[propertyIndex]); if (optionData[propertyIndex].nodeType == 1 && optionData[propertyIndex].nodeName == 'CustomFieldName2') custFieldName2 = getNodeText(optionData[propertyIndex]); if (optionData[propertyIndex].nodeType == 1 && optionData[propertyIndex].nodeName == 'CustomAction1') customAction1 = getNodeText(optionData[propertyIndex]); if (optionData[propertyIndex].nodeType == 1 && optionData[propertyIndex].nodeName == 'CustomAction2') customAction2 = getNodeText(optionData[propertyIndex]); if (optionData[propertyIndex].nodeType == 1 && optionData[propertyIndex].nodeName == 'Unit') sUnitValue = getNodeText(optionData[propertyIndex]); } if (selection){ optionObject = new Option(optionValue, optionID, false, false); selection.options[selection.length] = optionObject; selection.style.display = ''; if (el = document.getElementById('tr0')) { el.style.display='' } } } // if (selection) { optionObject1 = new Option('select', -1, false, false); selection.options[selection.length] = optionObject1; // } if (bReloadTree) { // strt += "\n"; selection.innerHTML = strt; } if (bPostAction==true) { var sPostSelection = document.getElementById(sPostName); sPostSelection.value = sPostValue; bPostAction = false; sPostName=''; sPostValue=''; } } // Retreives inner text of XML node (cross-browsing) function getNodeText(node) { return (node.textContent || node.innerText || node.text) ; } function verify_adding_new_adv(lifetime_tr, lifetime, maxlifetime) { ilifetime = document.getElementById(lifetime).value; if (ilifetime>0) { if (ilifetime <= maxlifetime) { //alert(lifetime_tr); return true; } document.getElementById(lifetime_tr).style.backgroundColor='red'; } return false;//errors in typing } /** * Update fields CustomFieldName1, CustomFieldName2, CustomAction1, CustomAction2 in table `Classifieds` * * @param $iEditAdvertisementID ID of edited Advertisement */ function AdmTryApplyChanges(sActionType, customNumber) { /*if (sActionType=="DeleteCustom") { document.getElementById('CustomName'+customNumber).value=""; document.getElementById('CustomAction'+customNumber).value="-1"; } var sName = document.getElementById('CustomName' + customNumber).value; var sAction = document.getElementById('CustomAction' + customNumber).value; var iIDcat = document.getElementById('FilterCat').value; sName = encodeURIComponent( sName ); sAction = encodeURIComponent ( sAction ); var sURLRequest = "dataType="+sActionType+"&iNumb="+customNumber+"&sName="+sName+"&sAction="+sAction+"&iIDcat="+iIDcat; AddRequestToQueue2(sURLRequest);*/ } /** * Update field Unit in table `Classifieds` * */ function AdmTryApplyUnitChanges(sActionType) { /*if (sActionType=="DeleteUnit") { document.getElementById('unit').value=""; } var iIDcat = document.getElementById('FilterCat').value; var sUnit = document.getElementById('unit').value; var sURLRequest = "dataType="+sActionType+"&sUnit="+encodeURIComponent(sUnit)+"&iIDcat="+iIDcat; AddRequestToQueue2(sURLRequest);*/ } function FilterReset(){ document.getElementById('tr1').style.display='none'; document.getElementById('tr2').style.display='none'; var el = document.getElementById('tr0'); if (el) { el.style.display='none'; } } function AddRequestToQueue2(sURLRequest) { requestsQueue[requestsQueue.length] = new QueueItem2(sURLGetList+sURLRequest); if (requestsQueue.length == 1) DoSendRequest2(); } function DoSendRequest2() { globalObjXmlHttpRequest = createXmlHttpObject(); if ( globalObjXmlHttpRequest ) { globalObjXmlHttpRequest.onreadystatechange = OnReadyStateChange; globalObjXmlHttpRequest.open("GET", requestsQueue[0].url); globalObjXmlHttpRequest.send(null); } } function QueueItem2(url) { this.url=url; } function OnReadyStateChange() { if(globalObjXmlHttpRequest.readyState == 4) { // Dequeue request and run the handler if ((requestData = requestsQueue.shift()) == null) throw new Error('Internal error: queue is empty'); } } function getCustomActionField(customTargetField) { var re = /(\d+)/; result = customTargetField.match(re); if (result[0]>0) { var oElement = document.getElementById('tr'+result[0]); return oElement; } } function AddCatFields(sFieldsCat, sAddLnk, sDelLnk) { if (document.getElementById(sFieldsCat).style.display == '') { document.getElementById(sFieldsCat).style.display = 'none'; document.getElementById(sDelLnk).style.display = ''; } else {//show and hide first Ad document.getElementById(sFieldsCat).style.display = ''; document.getElementById(sAddLnk).style.display = 'none'; document.getElementById(sDelLnk).style.display = 'none'; } } function UpdateField(sName, sValue){ var selection = document.getElementById(sName); selection.value = sValue; if (selection) { if (typeof(selection.onchange) == 'function') selection.onchange(); // Perform chain action } } function UpdateProgramFeature(sName, sValue){ var selection = document.getElementById(sName); selection.value = sValue; if (selection) { if (typeof(selection.onchange) == 'function'){ selection.onchange(); }// Perform chain action } } function UpdateFieldTiny(sName, sValue){ if (el = document.getElementById('commentText')) { document.getElementById('commentText').value = sValue; if (typeof tinyMCE != 'undefined') { tinyMCE.activeEditor.load(); //tinyMCE.execInstanceCommand('commentText', "mceFocus"); } } } function UpdateFields(sName, sValue, sName2, sValue2){ sPostName = sName2; sPostValue = sValue2; bPostAction = true; var selection = document.getElementById(sName); selection.value = sValue; if (selection) { if (typeof(selection.onchange) == 'function') selection.onchange(); // Perform chain action } } function UpdateFieldByInnerHtml(sName, sValue){ document.getElementById(sName).value = document.getElementById(sValue).innerHTML; } function UpdateFieldStyle(sName, sStyle){ document.getElementById(sName).style.display = sStyle; } function validateMusicFiles(){ var uploadMusic=document.getElementById('uploadedfile').value; var musictitle=document.getElementById('filetitle').value; var artistname=document.getElementById('artistname').value; var albumname=document.getElementById('albumname').value; var tagname=document.getElementById('tagname').value; var categories=document.getElementById('selbox').value; var description=document.getElementById('description').value; if(uploadMusic==''){ alert('please select any music file'); return false; } if(musictitle==''){ alert('please fill music title'); return false; } if(artistname==''){ alert('please fill artist name'); return false; } if(albumname==''){ alert('please fill album name'); return false; } if(tagname==''){ alert('please fill tagname name'); return false; } if(categories==''){ alert('please select categories'); return false; } if(description==''){ alert('please fill description'); return false; } } function checkPoadcast() { var city=document.getElementById('city').value; var categories=document.getElementById('categories').value; var poadcasttitle=document.getElementById('poadcasttitle').value; var briefdescreption=document.getElementById('briefdescreption').value; var descreption=document.getElementById('descreption').value; if(city==''){ alert('please select city'); return false; } if(categories==''){ alert('please select categories'); return false; } if(poadcasttitle==''){ alert('please fill poadcasttitle'); return false; } if(briefdescreption==''){ alert('please fill brief descreption'); return false; } if(descreption==''){ alert('please fill descreption'); return false; } else{ return true; } } function checkEpisode() { var episodetitle=document.getElementById('episodetitle').value; var descreption=document.getElementById('descreption').value; var uploadedfile=document.getElementById('uploadedfile').value; if(episodetitle==''){ alert('please fill episode title'); return false; } if(descreption==''){ alert('please fill descreption'); return false; } if(uploadedfile==''){ alert('please fill uploadedfile'); return false; } }