function checkMinBid(obj, obj2, str){
	if(obj.value < obj2){
		obj.focus();
		alert(str);
		return false;
	} else return true;
}

function checkMe(tf,pars){
	pole=pars.split(',');
	for(i=0;i<pole.length;i+=2){
		if(eval('tf.'+pole[i]+'.value')==''){
			alert(pole[(i+1)]+' is required.');
			eval('tf.'+pole[i]+'.focus()');
			return false;
		}
	}
	return true;
}

function confirm_window(text,ok,storno){
	if (confirm(text)){
		document.location=ok;
	}
	else{
		document.location=storno;
	}
	return false;
}


function makeWindow(url)
{
	window.open(url, '', "toolbar=no,status=no,scrollbars=no,resizable=yes,width=700,height=400");
}
function makePortfolio(url)
{
	window.open(url, '', "toolbar=yes,status=yes,scrollbars=yes,resizable=yes,width=600,height=400");
}
function newWindow(url)
{
	window.open(url, 'NEWW', "");
}
function dShowNew(co, jo) {
	var od=document.getElementById('f'+co);
	if(jo) {
	od.style.visibility='display';
	}else{
	od.style.visibility='hidden';
	}
	//alert(od.style.display);
	//od.style.display=(jo ? "''" : "'none'");
}
function dShow(co, jo, timg) {
	img="obr_"+co;
	co="f"+co;
	///alert( ((document.body.scrollTop-timg.offsetParent.offsetTop)+timg.offsetParent.offsetTop+150)+" # "+document.body.scrollTop+" # "+timg.offsetParent.offsetTop+" # "+timg.offsetParent.offsetParent.offsetTop);
	pozice=timg.offsetParent.offsetTop+timg.offsetParent.offsetParent.offsetTop+150;
	if (document.all) {
		eval(co + ".style.visibility = " + (jo ? "'visible'" : "'hidden'"));
		eval(co + ".style.posTop = " + pozice);
	} else {
  		document.layers[co].visibility = (jo ? "show" : "hide");
  		
  }
}

function calWindow(url){
	window.open(url, '', "toolbar=no,status=no,scrollbars=no,resizable=yes,width=650,height=200");
}

// attach func function to window onload event (crossbrowser compatible)
function attachOnloadEvent(func) {
	if(typeof window.addEventListener != 'undefined') {
		// moz, saf1.2, ow5b6.1
		window.addEventListener('load', func, false);
	} else if (typeof document.addEventListener != 'undefined') {
		// MSN/OSX, op7.50, saf1.2, ow5b6.1
		document.addEventListener('load', func, false);
	} else if (typeof window.attachEvent != 'undefined') {
		// ie5.0w, ie5.5w, ie6w
		window.attachEvent('onload', func);
	} else {
		// all other browsers
		if (typeof window.onload == 'function') {
			var oldonload = onload;
			window.onload = function() {
				oldonload();
				func();
			};
		} else {
				window.onload = func;
		}
	}
}

function divSwapDisplay(divName){
	var myDiv=document.getElementById(divName);
	var myStyle=myDiv.style.display;
	if(myStyle==''){
		myDiv.style.display='none';
	}else{
		myDiv.style.display='';
	}
	return true;
}

function processCatalogAdvancedFilter(){
	var myDiv = document.getElementById('advancedFilter');
	var hDiv  = document.getElementById('advancedFilterHeader');
	
	if(myDiv && hDiv){
	    if (myDiv.style.display != 'none') {
		    myDiv.style.display='none';
		    //hDiv.style.class = 'newLineLastLine';
		    
		    hDiv.setAttribute("class", "newLineLastLine"); 
            hDiv.setAttribute("className", "newLineLastLine"); 
		} else {
		    myDiv.style.display='';
		    //hDiv.style.class = 'newLine';
		    
		    hDiv.setAttribute("class", "newLine"); 
            hDiv.setAttribute("className", "newLine"); 		    
		}
	}
	return true;
}

// photogallery support

var photogallery = {
    CurrentPage:1,
    Items:0,
    ItemsPerPage:1,
    MaxPage:1,
    DivPrefix:"",
    Init:_pg_Init,
    ShowPage:_pg_ShowPage,
    SetVisible:_pg_SetVisible,
    InitDisplay:_pg_InitDisplay,
    SetControls:_pg_SetControls,
    PrevPage:_pg_PrevPage,    
    NextPage:_pg_NextPage
}

// gallery init
function _pg_Init(nItems, nItemsPerPage, sDivPrefix) {
    var el

    this.Items = nItems;
    this.ItemsPerPage = nItemsPerPage;
    this.DivPrefix = sDivPrefix
    
    // compute max page
    this.MaxPage = Math.ceil(nItems / nItemsPerPage);
    
    // controls init
    el = document.getElementById('pgc_prev');
    if (el) {
        this._prevElSrc = el.src;
    }    
    el = document.getElementById('pgc_next');
    if (el) {
        this._nextElSrc = el.src;
    }    
    
    // show first page...    
    this.InitDisplay();
    // set control for current page
    this.SetControls()    
}

// init display, show only first page..
function _pg_InitDisplay() {
    var el
    for (var i = this.ItemsPerPage + 1; i <= this.Items; i++) {
        el = document.getElementById(this.DivPrefix + i)
        if (el) {
            el.style.visibility='hidden';
            el.style.display='none';
        }
    }    
}

// set control for current page
function _pg_SetControls() {
    var prevEl, nextEl
    
    prevEl = document.getElementById('pgc_prev');
    nextEl = document.getElementById('pgc_next');    

    if (this.CurrentPage > 1) {
        if (prevEl) {
            prevEl.src = this._prevElSrc;
        }
    } else {
        if (prevEl) {
            prevEl.src = this._prevElSrc.replace('.gif', '-grey.gif');
        }        
    }
    
   if (this.CurrentPage < this.MaxPage) {
        if (prevEl) {
            nextEl.src = this._nextElSrc;
        }
    } else {
        if (prevEl) {        
            nextEl.src = this._nextElSrc.replace('.gif', '-grey.gif');
        }        
    }    
}

// show concrete photogallery page...
function _pg_ShowPage(nPage) {
    if (nPage != this.CurrentPage) {
        this.SetVisible(this.CurrentPage, 'hidden', 'none')
        this.SetVisible(nPage, 'visible', 'block')
        this.CurrentPage = nPage
        this.SetControls()
    }
}

function _pg_SetVisible(nPage, sVisibility, sDisplay) {
    var el;
    if (nPage > 0 && nPage <= this.MaxPage) {
        for (var i = (nPage - 1) * this.ItemsPerPage + 1; i<= nPage * this.ItemsPerPage; i++) {
            el = document.getElementById(this.DivPrefix + i)
            if (el) {
                el.style.visibility=sVisibility;
                el.style.display=sDisplay;                
            }            
        }    
    }
}

// set prev page and set controls
function _pg_PrevPage() {
    if (this.CurrentPage > 1) {
        this.ShowPage(this.CurrentPage - 1)
    }
    return false;    
}

// set next page and set controls
function _pg_NextPage() {
    if (this.CurrentPage < this.MaxPage) {
        this.ShowPage(this.CurrentPage + 1)
    }
    return false;
}


