RE: How to switch over to the Modal?
If it is really a Modal Window, then you do not need to be use the switch command. Just get the id or xpath of it and do your operations on it. Modal window is always a part of same html page. Make sure you use the thread.sleep() before clicking any element on Modal window, as it is generated with the java script and sometime it takes one or more seconds to appear on the page but Selenium did not understand this delay, as it is a same page and it tries to perform action with in fractions of second and it got failed.
Example of modal window, most of the time it covers the background with transparent black wallpaper and on top it the window display.
If it is not Modal window and if it is a pop up alert try below code, this may help you.
// Get a handle to the open alert, prompt or confirmation Alert alert = driver.switchTo().alert(); //Will Click on OK button. alert.accept(); // Will click on Cancel button. alert.dismiss()