var current_link = '';
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
function showList (selectedLink) {
if (document.getElementById) {
oldLink = selectedLink.href;
current_link = selectedLink.href
newLink = oldLink.replace('/index.php?' , '/productsListXML.php?');
document.getElementById("contents").innerHTML = "

Loading...
";
if (postAJAX(newLink, "", loadProductsList)) {
return false;
} else {
return true;
}
} else {
return true;
}
}
// Processes the information from a returned count XML
function loadProductsList()
{
if (request.readyState == 4) {
if (response = request.responseText) {
document.getElementById("contents").innerHTML = response;
prepareListsLinks("pager_bottom");
prepareListsLinks("pager_top");
prepareListForms("pList");
prepareLanguageLinks("languages");
initLightbox();
prepareFormCalendar("date_time");
} else {
// form.submit();
}
}
}
function prepareLanguageLinks(divId){
var languages = document.getElementById( divId );
var links = languages.getElementsByTagName( 'a' );
current_link = current_link.replace('/productsListXML.php?' , '/index.php?');
current_link = current_link.replace('&language=en?' , '');
current_link = current_link.replace('&language=sr?' , '');
languages.innerHTML = 'English | Srpski';
};
function prepareListsLinks( divId ){
if( document.getElementById &&
document.getElementsByTagName ){
if( document.getElementById( divId ) ){
var gallery = document.getElementById( divId );
var links = gallery.getElementsByTagName( 'a' );
for( var i=0; i < links.length; i++ ){
links[i].onclick = function(){
return showList(this);
};
}
}
}
}
function prepareListForms( divId ){
if( document.getElementById && document.getElementsByTagName ){
if(document.getElementById(divId)){
//alert(divId);
var gallery = document.getElementById( divId );
var links = gallery.getElementsByTagName( 'form' );
for( var i=0; i < links.length; i++ ){
//alert (links[i].name);
links[i].onsubmit = function(){
//alert (this.name);
//return false;
return check_form(this);
};
}
}
}
}
function prepareFormCalendar( divId ){
if( document.getElementById && document.getElementsByTagName ){
if(document.getElementById(divId)){
//alert(divId);
var gallery = document.getElementById( divId );
var links = gallery.getElementsByTagName( 'form' );
for( var i=0; i < links.length; i++ ){
//alert (links[i].name);
links[i].delivery_date_mask.disabled=true;
links[i].onsubmit = function(){
//alert (this.name);
//return false;
return check_form_calendar(this);
};
}
}
}
}
addLoadEvent(function() {
prepareListsLinks("categories_list");
prepareListsLinks("pager_bottom");
prepareListsLinks("pager_top");
prepareListForms("pList");
initLightbox();
prepareFormCalendar("date_time");
})
/*
addLoadEvent(prepareCategoryLinks);
addLoadEvent(preparePagerLinks);*/