var gMenustrip;
var q_menulist=new Array(
new Array("File","Close","<hr>","Quit"));
var gJM;
var gTotalimagesize=0;
var gLoadedimagesize=0;

function speedform_load(){
if(ALERT==""){
	setEnvironmentInfo(gLIVEID,(gVERIFYPLAYER=="1"));
	if(document.getElementById("STARTIMMEDIATELY")){
		doRunshow(1);
		if(document.getElementById("buttonBack")){
		}else{
			 //window.close();
		}//end if
	}else{
		CreateMenustrip();
		setTimeout("preloadslides(JAVALOADIMAGES)",3000);
		//setTimeout(""q_proccheckslideload()"",3000);
	}//end if
	if(contains(gPLAYERS,"WM")){
		if(WIN()&&FX()&&!hasWMforFirefox()){
			yellowmessage(uText(24,"Using Firefox with Windows Media requires the <br><a href=http://port25.technet.com/pages/windows-media-player-firefox-plugin-download.aspx target=_blank>updated Windows Media plugin for Firefox</a>\nfor slide synchronization."));
		}else if(WIN()&&FX3()){
			//yellowmessage(uText(37,"For Windows Media, Internet Explorer is recommended."));
		}//end if
		
		if(MAC()){
			yellowmessage(uText(25,"Mac users, please use the <a href='http://www.microsoft.com/windows/windowsmedia/player/wmcomponents.mspx'>Flip4Mac</a> plugin. Also make sure to enable <b>streaming</b> using the <a href='../../../program/livepro/admin/flip4mac.htm' target=_blank>Flip4Mac streaming settings</a>"));
		}//end if
	}//end if
}else{
	CreateMenustrip();
	yellowmessage(ALERT);
//	setEnvironmentInfo(gLIVEID);
	if(gRECHECKING=="1"){
	recheckCount=parseInt(gTIMELEFT);
	setPulse();
	}//end if
}//end if
}//end function

function requiredScreenWidth(STREAMID){
try{
envRequirement=gStreamlist[STREAMID][16];
if(contains(envRequirement,"/")){
	return myLng(envRequirement.split("/")[3]);
}else{
	return 0;
}//end if
}catch(errObj){
	return 0;
}//end catch
}//end function

function hasWMforFirefox(){
if (document.WMP7){
	if(document.WMP7.versionInfo){
		return true;
	}else{
		return false;
	}//end if
}else{
	return false;
}//end if	
}//end function

var recheckCount=59;
function setPulse(){
recheckCount=recheckCount-1;
if(recheckCount>0){
	yellowmessage(ALERT+uText(26,"\n\nPlease stand by - rechecking in [ z_seconds ] seconds...").replace("z_seconds",recheckCount));
	setTimeout("setPulse()",998);
}else{
	document.location.reload();
}//end if
}//end function

function CreateMenustrip(){
var q_obj=document.getElementById("MenustripGraphic");
if(q_obj){
var q_itemnumber=3;
addMenuWindowHelp(q_menulist);
gMenustrip=new Menustrip(Menustrip_OnSelectMenuitem);
gMenustrip.paint(q_obj,q_menulist,q_itemnumber,gIMG);
gMenustrip.removeMenuitem("Preview Show");
setMenuLivemode(gMenustrip,"Coverpage",CHANNEL);
}//end if
}//end function

//Menustrip Events
function Menustrip_OnSelectMenuitem(q_itemname){
switch (q_itemname){
case "Close":doNav(0,"a_main",gPRODUCER_ID,gFOLDERNAME);break;
case "Quit":doExit();break;
default: caseWindowHelp(0,q_itemname,gPRODUCER_ID,gFOLDERNAME);break;
}//end switch
}//end function

function buttonRequirements_Click(){
window.open(gHOMEBASE+"requirements.asp?FOLDERNAME=" + gFOLDERNAME+"&SHOWFOLDER=" + gSHOWFOLDER+"&PRODUCER_ID=" + gPRODUCER_ID ,"REQUIREMENTS","top=200,left=150,width=400,height=450");
}//end function

var gStarted=0;
var gShowWindow=0;
function doRunshow(STREAMID){
if(screen.width<requiredScreenWidth(STREAMID)){
	alert(translate("[se]Du behöver en större skärm för att se denna presentationen. (Minsta bredd [/se][en]You need higher screen resolution to view this presentation. (Minimum [/en]")+requiredScreenWidth(STREAMID)+translate(" [se]pixlar[/se][en]pixels wide[/en])"));
	return 0;
}else{
}//end if
q_resizable=(gRESIZABLE=="1")?"resizable,":"";
document.getElementById("STREAMID").value=STREAMID;
if(contains(""+STREAMID,".asp")||contains(""+STREAMID,".htm")){
	var q_URL=STREAMID;
}else if(gStreamlist[STREAMID][13]>""){
	var q_URL="../../../show/"+gPRODUCER_ID+"/"+gFOLDERNAME+"/mainshow.asp?"+jsParameters("form1")+"&KEY="+gKEY+"&TEMPLATENAME="+gStreamlist[STREAMID][13];
}else{
	var q_URL="../../../show/"+gPRODUCER_ID+"/"+gFOLDERNAME+"/mainshow.asp?"+jsParameters("form1")+"&KEY="+gKEY+"&CMP=1";
}//end if
if(FET(30) && gUSEPOPUP!="0"){
	if(window.name=="Mainshow"){
		resizeWindow(gMASTERWIDTH,gMASTERHEIGHT);
	}//end if
	var newWindowName=gPRODUCER_ID+"_"+gFOLDERNAME;
if(gStreamlist[STREAMID][14]>"" && gStreamlist[STREAMID][15]>""){
	gShowWindow=window.open(q_URL,newWindowName,q_resizable+"top=0,left=0,width="+parseInt(gStreamlist[STREAMID][14])+",height="+parseInt(gStreamlist[STREAMID][15]));
}else{
	gShowWindow=window.open(q_URL,newWindowName,q_resizable+"top=0,left=0,width="+gMASTERWIDTH+",height="+gMASTERHEIGHT);
}//end if
	gShowWindow.focus();
	if (gShowWindow==null || typeof(gShowWindow)=="undefined"){
		yellowmessage(textAllowPopups());
		if(gStarted==1){
			alert(textAllowPopups());
		}//end if
	}//end if
	gStarted=1;
}else{
	gStarted=1;
	document.location.href=q_URL;
}//end if
}//function

function resizeWindow(q_wid,q_hei){
	window.resizeTo(q_wid,q_hei);
	if(IE()){
	//window.resizeTo(q_wid+q_wid-document.body.offsetWidth+4,q_hei+q_hei-document.body.offsetHeight+3);
	}//end if
}//end function

function doRunRemoteshow(q_URL){
q_resizable=(gRESIZABLE=="1")?"resizable,":"";
document.getElementById("STREAMID").value=1;
document.getElementById("FOLDERNAME").value="";
q_URL=q_URL+"?"+jsParameters("form1")+"&KEY="+gKEY+"&CMP=1";
if(FET(30) && gUSEPOPUP!="0"){
	gShowWindow=window.open(q_URL,"Mainshow",q_resizable+"top=0,left=0,width="+gMASTERWIDTH+",height="+gMASTERHEIGHT);
	gShowWindow.focus();
	if (gShowWindow==null || typeof(gShowWindow)=="undefined"){
		yellowmessage(textAllowPopups());
		if(gStarted==1){
			alert(textAllowPopups());
		}//end if
	}//end if
	gStarted=1;
}else{
	gStarted=1;
	document.location.href=q_URL;
}//end if
}//function

function textAllowPopups(){
return uText(27,"The Webcast will open in a separate window, so you will need to Allow Popups. ");
}//function

function yellowmessage(msg){
		var info=document.getElementById("info");
		if(info){
			info.innerHTML=msg.replace(/\n/g, '<br>');
			info.className="yellowmessage";
//			info.style.backgroundColor="yellow";
//			info.style.borderWidth=1;
//			info.style.borderStyle="solid";
//			info.style.padding="3 3 3 3";
//			info.style.visibility="visible";
		}//end if
}//end function

function jsParameters(formid){
var q_elem=document.getElementById("form1").elements;
var q_str="";
var q_sep="";
for (var q_t=0;q_t<q_elem.length;q_t++){
	q_str=q_str + q_sep+q_elem[q_t].name +"="+escape(q_elem[q_t].value);
	q_sep="&";
}//next
return q_str;
}//end function

function checkEmail(ds){
if((ds.length < 6) || (ds.indexOf(' ') >=0)|| (ds.indexOf('@') ==-1)|| (ds.indexOf('.') == -1)){
	alert(uText(28,'Please correct the email address.'));
}//end if
}//end function

function checkSP2(){
 var g_fIsSP2 = (window.navigator.userAgent.indexOf("SV1") != -1);
  if (g_fIsSP2 && gUSEPOPUP!="0"){
      var info=document.getElementById("info");
	  if(info){
		info.innerText=textAllowPopups();
		//info.style.backgroundColor="yellow";
	  }//end if
    }//end if
}//end function

function preloadslides(q_jm){
checkSP2();
//return 0;
gJM=q_jm;
gTotalimagesize=sumsize(q_jm,q_jm.length);
q_preloadproc();
}//end function

function sumsize(q_jm,q_i){
var q_sum=0;
if (q_i>q_jm.length){
	q_i=q_jm.length;
}//end if
for (var q_t=0;q_t<q_i;q_t++){
	q_sum=q_sum+parseInt(q_jm[q_t][0]);
}//next
return q_sum;
}//end function

function q_preloadproc(){
var q_i=gPic.length;
if(q_i<gJM.length && gStarted==0){
//more to load
	if(q_i>0){
		if(!(gPic[gPic.length-1].complete)){
			setTimeout("q_preloadproc()",50);
			return 0;
		}//end if
	}//end if
	gPic[q_i]=new Image();
	gPic[q_i].src=gJM[q_i][1];
	gLoadedimagesize=gLoadedimagesize+parseInt(gJM[q_i][0]);
//	var q_p=Math.floor(100*q_i/gJM.length);
	var q_p=Math.floor(100*gLoadedimagesize/gTotalimagesize);
	q_setstatus(uText(29,"Loading...")+q_p+"%",q_p);
//	q_setstatus("Loading..."+gLoadedimagesize+"/"+gTotalimagesize,q_p);
	setTimeout("q_preloadproc()",100);
	return 0;
}else{
	q_setstatus("",100);
	return 1;
}//end if
}//end function

function q_getslideloadpercent(gPic){
var q_sum=0;
for (var q_t=0;q_t<gPic.length;q_t++){
	if (gPic[q_t].complete){
		q_sum=q_sum+1;
	}//endif
}//next
return Math.floor(100*q_sum/gPic.length);
}//end function

function q_proccheckslideload(){
var q_p=q_getslideloadpercent(gPic);
q_setstatus(uText(29,"Loading...")+q_p+"%",q_p);
if(q_p<100){
	setTimeout("q_proccheckslideload()",500);
}//end if
}//end function

function q_setstatus(astr){
var q_obj=document.getElementById("status");
if(q_obj){
	q_obj.innerHTML=astr;
}//end if
}//end function

function uText(id,txt){
if(gLANGUAGE!="se"){
	return txt;
}else{
	switch(id){
	case 24:return "Firefox användare behöver<br><a href=http://port25.technet.com/pages/windows-media-player-firefox-plugin-download.aspx target=_blank>Port25 Windows Media Player Firefox Plugin</a>\n";
	case 25:return "Mac användare behöver <a href='http://www.microsoft.com/windows/windowsmedia/player/wmcomponents.mspx'>Flip4Mac</a> pluginen. Se även till att aktivera <b>streaming</b> med <a href='../../../program/livepro/admin/flip4mac.htm' target=_blank>Flip4Mac streaming settings</a>";
	case 26:return "\n\nVänligen vänta - uppdaterar om [ z_seconds ] sekunder...";
	case 27:return "Filmen öppnas i ett nytt fönster, så du behöver tillåta popupfönster.";
	case 28:return "Korrigera email addressen.";
	case 29:return "Laddar...";
	case 37: return "Vi rekommenderar Internet Explorer för att spela Windows Media.";
	default:return txt;
	}//end switch
}//end if
}//end function



