
/* page: Global --> */

		var currentNumberID = null;
        var searchResult = new Array();

        function numberHover( oldid, newid ) {

            oldid = oldid ? oldid : currentNumberID;
            if (oldid != null) {
                obj = _obj('num_'+searchResult[oldid]);
                obj.className = 'auto-complete-row';
            }
            currentNumberID = newid;
            obj = _obj('num_'+searchResult[newid]);
            obj.className = 'auto-complete-row-hover';

        }

        function numberNavigate( id ) {

            _href( siteUrl+"?do=slideview&nid=" + searchResult[id] );

        }

		function numberSearch(text) {

            if (global_key != null && global_key == 40) { //down

                if (currentNumberID == null)
                    numberHover(null, 0);
                else if (currentNumberID < searchResult.length-1)
                    numberHover(currentNumberID, currentNumberID+1);

            } else if (global_key != null && global_key == 38) { //up

                if (currentNumberID == null)
                    numberHover(null, searchResult.length-1);
                else if (currentNumberID > 0)
                    numberHover(currentNumberID, currentNumberID-1);

            } else if (global_key != null && global_key == 13) { //enter

                if (currentNumberID != null) numberNavigate(currentNumberID);

            } else

			if (text.length > 1) {

                searchResult = new Array();
				text.toString();
				text = text.toUpperCase();

				var content = '';

				for (var i = 0; i < numberCollection.length; i++) {

					if (numberCollection[i].indexOf(text) > -1) {

                        searchResult[searchResult.length] = numberIDs[i];
                        var l = searchResult.length - 1;
						content += '<div id="num_' + numberIDs[i] + '" class="auto-complete-row" onmouseover="numberHover(null, ' + (searchResult.length-1) + ');" onclick="numberNavigate('+l+');">' + numberCollection[i].replace( text, '<b>'+text+'<\/b>' ) + '<\/div>';

					}

				}

				if (content.length <= 0) content = "Not Found";
				reattach('num-search', content, true);
                currentNumberID = null;
                listenKey();
				//showFloatWindow('num-search');

			} else {

				hideFloatWindow();
                nolistenKey();

			}

		}

/* <-- page: Global */

/* page: Collection --> */

            function showPhoto( fn ) {

                showLightbox( photoUrl + fn );

            }

            function changeCollection( new_type ) {

                if (new_type == collectionType[0]) return;

				collectionType[1] = collectionType[0];
				collectionType[0] = new_type;

                var url = siteUrl+"?do=collection&type="+collectionType[0];

                ajaxObj = new ajaxRequest;
				//ajaxObj.init();
				ajaxObj.feedback = ajaxFeedbackCollection;

				_obj('tab_'+collectionType[0]).style.cursor = 'progress';
				ajaxObj.process( url, 'GET' );

            }

            function ajaxFeedbackCollection() {
				_obj('tab_'+collectionType[1]).className = 'tabInactive';
				_obj('collection').innerHTML = ajaxObj.getText();
				_obj('tab_'+collectionType[0]).style.cursor = '';
				_obj('tab_'+collectionType[0]).className = 'tabActive';
			}

/* <-- page: Collection */

/* page: SlideView --> */

            var autoSlide = 0;

            function slideProgress() {

                _obj('slide-status').innerHTML = (currentSlide + 1)+'/'+(slideNumberCount+1);
                _obj('slide-progress-image').style.width = Math.ceil((currentSlide+1)/(slideNumberCount+1)*(_obj('slide-progress-cell').offsetWidth-3))+"px";

            }

            function slide( way ) {

                if (slideNumberCount == 0) return;

                if (way == -1 && currentSlide == 0) {
                    currentSlide = slideNumberCount;
                } else if (way == 1 && currentSlide == slideNumberCount) {
                    currentSlide = 0;
                } else {
                    currentSlide += way;
                }

                var url = slideUrl+"&limit="+currentSlide;
                ajaxObj = new ajaxRequest();
                ajaxObj.feedback = ajaxFeedbackSlide;
                ajaxObj.process( url );

            }

            function ajaxFeedbackSlide() {

                var num = ajaxObj.getByXML('num');
                var country = ajaxObj.getByXML('country');
                if (country != 'LV' && country != 'N/A') num += ' ('+country+')';

                var tmpImage = new Image();
                tmpImage.onload = function() {
                	_obj('slide_navi0').innerHTML = num;
                	_obj('slide_navi1').innerHTML = num;
                	_obj('slide_image').src = ajaxObj.getByXML('image');
                	_obj('slide_num').innerHTML = num;
                	_obj('slide_model').innerHTML = ajaxObj.getByXML('model');
                	_obj('slideNumberCountry').innerHTML = country;
                	_obj('slide_user').innerHTML = ajaxObj.getByXML('user');
                	_obj('slide_date').innerHTML = ajaxObj.getByXML('added');
                	_obj('slide_first').innerHTML = ajaxObj.getByXML('is_first');
                	slideProgress();
                }
				tmpImage.src = ajaxObj.getByXML('image');
            }

            function setStaticInfo( oname ) {

                var obj = _obj( oname );
                setCookie( 'ads-pos-'+oname , '' );

                obj.style.marginTop = '10px';
                obj.style.position = '';
                obj.style.left = '';
                obj.style.top = '';

            }

            function toggleAutoSlide( delay ) {

            	if (autoSlide == 0) {

            		_obj('auto-slide-status').src = imageUrl+"on.gif";
            		//autoSlide = 1;
            		_obj('auto-slide-button').onclick = toggleAutoSlide;
            		delay = delay * 1000;
            		autoSlide = window.setTimeout( 'autoSlideStep('+delay+')', delay);

            	} else {

            		_obj('auto-slide-status').src = imageUrl+"off.gif";
            		//autoSlide = 0;
            		attachClick('auto-slide-button');
            		window.clearTimeout(autoSlide);
            		autoSlide = 0;

            	}

            }

            function autoSlideStep( delay ) {

				if (autoSlide != 0) {

					slide(1);
					window.clearTimeout(autoSlide);
					autoSlide = window.setTimeout( 'autoSlideStep('+delay+')', delay);

				}

            }

/* <-- page: SlideView */

/* page: HowToAdd --> */

	function uploadFormCheck(form) {

		if (form.agreement.checked == false) {
			alert(mustAgree);
			return false;
		} else {
			return true;
		}
	}

/* <-- page: HowToAdd */
