# When i write this method all of JS stops working!

**URL:** https://forum.kirupa.com/t/when-i-write-this-method-all-of-js-stops-working/206577
**Category:** Uncategorized
**Created:** [November 9, 2006, 3:16pm UTC](https://forum.kirupa.com/t/when-i-write-this-method-all-of-js-stops-working/206577 "2006-11-09T15:16:56Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Binji](https://avatars.discourse-cdn.com/v4/letter/b/cdc98d/32.png) [@Binji](https://forum.kirupa.com/u/Binji)
#### Post date: [November 9, 2006, 3:16pm UTC](https://forum.kirupa.com/t/when-i-write-this-method-all-of-js-stops-working/206577/1 "2006-11-09T15:16:56Z")

</div>

Every time i add this function to my JS file everything stops working. Including alerts, rollovers…everything! Can anyone tell me what could be the problem?

```auto

function gSlike(desno, stGalerije){
    if(desno){ //if the right button is pressed
        curImage++;
        if(curImage>12){
            curImage=1;
        }
    }else{ 
        curImage--;
        if(curImage<1){
            curImage=12;
        }
    }
    switch('velika', 'images/velike/'+stGalerije+'_'+curImage+'.png';
}

```

It’s supposed to be the code for left and right buttons which control displaying images on the website. The “switch” functions works because i use it also for when user clicks on the thumbnail image.
