// ******************************************************************************************************
// Function to popup url or image in new window
// ******************************************************************************************************
function PopUpGeneric(URL, width, height)
	{
	// Popup window with links to image library. 
	var popleft=((document.body.clientWidth - 440) / 2)+window.screenLeft; 
	var poptop=(((document.body.clientHeight - 460) / 2))+window.screenTop-40;		
	window.open(URL,"_blank","resizable=1,scrollbars=auto,width=" + width + ",height=" + height + ",left="+popleft+",top="+poptop)
	}

// ******************************************************************************************************
// Function for poping-up images : Reference it like this in the html: 
// <a href="javascript:;" onClick="PopUpImg('jpg','/assets/layout/my_image.jpg','640','480','Image 1','0','0')">Click!</a> 
// ******************************************************************************************************
function PopUpImg(imageType,imageName,imageWidth,imageHeight,alt,posLeft,posTop) {
 screenh = window.screen.height;
 screenw = window.screen.width;
 posLeft = (screenw-imageWidth)/2;
 posTop = (screenh-imageHeight)/2;
 theWindow = window.open("","theWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+posLeft+",top="+posTop);
 theWindow.document.open();
 theWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">');
 theWindow.document.write('<img src="'+imageName+'" width='+imageWidth+' height='+imageHeight+' alt="'+alt+'" onClick="javascript:window.self.close();" galleryimg="no">');
 theWindow.document.write('</body></html>');
 theWindow.document.close();
 theWindow.focus()
}

// ******************************************************************************************************
// Function that displays wait message when submitting a form
// css-style: .waitMsg {visibility:hidden; color: red; }
// sample code: <span class="waitMsg" ID="id_waitmsg">Loading Data. Please Wait...<br><img id=pbar src="/assets/shop/layout/loading.gif"></span>
// ******************************************************************************************************
function ShowWaitMsg()
{
if(id_waitmsg) id_waitmsg.style.visibility = 'visible';
setTimeout('document.images["pbar"].src = "/assets/shop/layout/loading.gif"', 200);
}

// ******************************************************************************************************
// Function to open help i Editor area
// ******************************************************************************************************
function OpenHelp(){
window.open("/Editor/Editor_help/help.htm","Help","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=770,height=550");
			}

function SaveCourse()
 {
 var msg = "Du måste fylla i" + ":\n";
 document.forms[0].elements.inpContent.value = oEdit1.getHTMLBody();

 checkEmail = document.forms[0].str_contactemail.value
 if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.'))) 
 { msg += ("\n - Fylla i en korrekt emailadress"); }

 if (document.forms[0].str_coursetitle.value == '') { msg += ("\n - Kurstitel");}
 if (document.forms[0].str_courselength.value == '') { msg += ("\n - Kurslängd");}
 if (document.forms[0].dte_startdate.value == '') { msg += ("\n - Startdatum");}
 if (document.forms[0].dte_enddate.value == '') { msg += ("\n - Slutdatum");}
 if (document.forms[0].dte_lastregdate.value == '') { msg += ("\n - Sista anmälningsdag");}
 if (document.forms[0].str_courselocation.value == '') { msg += ("\n - Kursort");}
 if (document.forms[0].dbl_coursefee.value == '') { msg += ("\n - Kursavgift");}
 if (document.forms[0].dbl_memberdiscount.value == '') { msg += ("\n - Medlemsrabatt");}
 if (document.forms[0].str_coursetrainers.value == '') { msg += ("\n - Kursledare");}
 if (document.forms[0].inpContent.value == '') { msg += ("\n - information om kursen");}

 if (msg != "Du måste fylla i" + ":\n") {
  alert(msg)
  return;
  }

 else 
 { 
  document.forms[0].submit() 
  }
 
 }

function ExitCourse(url_course_id)
 {
 var msg = "Du måste fylla i" + ":\n";
 document.forms[0].elements.inpContent.value = oEdit1.getHTMLBody();

 checkEmail = document.forms[0].str_contactemail.value
 if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.'))) 
 { msg += ("\n - Fylla i en korrekt emailadress"); }

 if (document.forms[0].str_coursetitle.value == '') { msg += ("\n - Kurstitel");}
 if (document.forms[0].str_courselength.value == '') { msg += ("\n - Kurslängd");}
 if (document.forms[0].dte_startdate.value == '') { msg += ("\n - Startdatum");}
 if (document.forms[0].dte_enddate.value == '') { msg += ("\n - Slutdatum");}
 if (document.forms[0].dte_lastregdate.value == '') { msg += ("\n - Sista anmälningsdag");}
 if (document.forms[0].str_courselocation.value == '') { msg += ("\n - Kursort");}
 if (document.forms[0].dbl_coursefee.value == '') { msg += ("\n - Kursavgift");}
 if (document.forms[0].dbl_memberdiscount.value == '') { msg += ("\n - Medlemsrabatt");}
 if (document.forms[0].str_coursetrainers.value == '') { msg += ("\n - Kursledare");}
 if (document.forms[0].inpContent.value == '') { msg += ("\n - information om kursen");}

 if (msg != "Du måste fylla i" + ":\n") {
  alert(msg)
  return;
  }

 else 
 { 
  // document.forms[0].submit() 
  gotoURL(url_course_id)
  }
 
 }


// ***************************************
// Function to roll over images
// **************************************
 function roll_over(img_name, img_src)
 { document[img_name].src = img_src; }