var main_station_url;
main_station_url = "http://nick8.surfernetwork.com/Media/player/scripts/playerp2Fail.aspx" + newstationadr;
//main_station_url = "mms://nick12a.surfernetwork.com/KYKXFILES/200909112030kykx.wma";
/** main_station_gw is in player/scripts/surfer_ajax_plugin.js **/

function gw_count_click(x){
        var int_gw_AdID = eval("gw_AdID" + x);
        reportTrafficStat(int_gw_AdID,qcallsign,sn_success_status,1);  //adid, qcallsign, success
}        

function gw_start_gateway(x){
        var int_replace_type = eval("gw_ReplacementType" + x);
        var int_banner_url = eval("gw_CompBannerFileName" + x);
        var int_click_target = eval("gw_CompBannerClickTarget" + x);
        var int_gw_AdID = eval("gw_AdID" + x);
        
        if(int_replace_type == 10){
        document.getElementById('gateway_div').style.left = "0px";
        } else if (int_replace_type == 11){
			if(int_click_target != ""){
				document.getElementById('gateway_img_div').innerHTML = "<a onclick='gw_count_click(" + x + ")' href='" + int_click_target + "' target='_blank'><img src='" + int_banner_url + "' border='0'></a>";
			} else {
				document.getElementById('gateway_img_div').innerHTML = "<img src='" + int_banner_url + "' border='0'>";
			}
		document.getElementById('gateway_img_div').style.left = "0px";
        } 
        document.WM_Gateway.controls.stop(); document.WM_Gateway.URL = main_station_gw; setTimeout("document.WM_Gateway.controls.play()",200);
        sn_success_status = "True";
        reportTrafficStat(int_gw_AdID,qcallsign,sn_success_status,0);  //adid, qcallsign, success
        sn_success_status = "False";        
}

function gw_start_main(){
         document.Player.controls.stop();
         document.Player.URL = main_station_url;
         if(document.getElementById('playerURLdisplay')){document.getElementById('playerURLdisplay').innerHTML = main_station_url;}
         live_player = 'Player';
         eval("document." + live_player + ".settings.volume = " + main_player_vol)
         setTimeout("document.Player.controls.play()",400);
}

function startup_sequence(){
	   if (gw_count == 1){
			 start_banners = 0;
			 live_player = "WM_Gateway";
			 gw_start_gateway(1);
			 setTimeout("gw_start_main();", gw_Duration1*1000);
			 setTimeout("document.getElementById('gateway_div').style.left = '1270px'; document.getElementById('gateway_img_div').style.left = '1270px'; start_banners = 1; live_player = 'Player'; start_300_banners(); start_728_banners();", gw_Duration1*1000 + 100);
	   } else if (gw_count == 2){
			 start_banners = 0;
			 live_player = "WM_Gateway";
			 gw_start_gateway(1);
			 main_station_gw = gw_AdFileName2;
			 setTimeout("gw_start_gateway(2);", gw_Duration1*1000);
			 setTimeout("gw_start_main();", (1*gw_Duration1 + 1*gw_Duration2)*1000);
			 setTimeout("document.getElementById('gateway_div').style.left = '1270px'; document.getElementById('gateway_img_div').style.left = '1270px'; start_banners = 1; live_player = 'Player'; start_300_banners(); start_728_banners();", (1*gw_Duration1 + 1*gw_Duration2)*1000 + 100);
	   } else {
			 gw_start_main();
	   }
}

var iframe_url = "http://www.surfernetwork.com";
var snx = "<div id='playerObjectK' style='font-size: 16pt; width: 728px; height: 90px; position: absolute; top: 600px; left: 26px; background-color: #cccccc; z-index: 64;'>";
    snx = snx + "<iframe id='ra_iframe' style='width: 728px; height: 90px; overflow: hidden;' frameborder='0' scrolling='no' src=''></iframe>";
    snx = snx + "</div>";
if(document.getElementById('new_ad_container')){document.write(snx); document.getElementById('ra_iframe').src =  iframe_url;};
/*
document.write("<div id=\"debug1\" style=\"position: absolute; top: 410px; left: 0px; width: 470px; height: 100px; font-size: 10pt; color: #222222; background-color: #dddddd;\"></div>");

         nvstring += "The gateway count is " + gw_count + "<br>The AdID1 is " + gw_AdID1 + "<br>The AdFileName1 is " + gw_AdFileName1 + "<br>The main_station_gw is " + main_station_gw + "<br>Duration1 is " + gw_Duration1; 
	     nvstring += " seconds<br>MediaType1 is " + gw_MediaType1 + "<br>ReplacementType1 is " + gw_ReplacementType1 + "<br>ClickTarget1 is " + gw_ClickTarget1 + "<br>";

	     document.getElementById('debug1').innerHTML = nvstring;
*/

//setTimeout("startup_sequence()", 1000); Moved this to OnLoad()

