// ******************************************************************************************************
// 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");
			}

// *************************************//
// Script top Preload and Swap Images //
//(c) SystemDesign SE AB, 2007 //
// *************************************//
function roll_over(img_name, img_src)
 { 
  document[img_name].src = img_src;
 }

function roll_out(img_name, img_src)
 { 
  document[img_name].src = img_src;
 }

 // **************************************************************
 // Functions for handling registration form (registration fee)
 // **************************************************************
 
 // ******************************* //
 // Check registration form
 // ******************************* //
 function checkForm()
 {
 var msg
 var pattern = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
 msg = "You must enter" + ":\n";

 //if (!validRadio(document.forms.register.sel_currency)) 
    //{ msg += ("- Registration fee\n"); }

 if (document.forms.register.sel_currency.value == '')
	{ msg += ("- Registration fee" + "\n"); }

 if (!validRadio(document.forms.register.ptitle)) 
    { msg += ("- Your title\n"); }
 
 if (document.forms.register.firstname.value == '')
	{ msg += ("- Firstname" + "\n"); }

 if (document.forms.register.surname.value == '')
	{ msg += ("- Surname" + "\n"); }

 if (document.forms.register.address_1.value == '')
	{ msg += ("- Address 1" + "\n"); }

 if (document.forms.register.postalcode.value == '')
	{ msg += ("- PO Code" + "\n"); }

 if (document.forms.register.city.value == '')
	{ msg += ("- City" + "\n"); }

 if (document.forms.register.country.value == '')
	{ msg += ("- Country" + "\n"); }

 if (document.forms.register.phone.value == '')
	{ msg += ("- Phone" + "\n"); }

 if(!pattern.test(document.forms.register.email.value))
	{ msg += ("- A correct email address" + "\n"); }

	if (msg != "You must enter" + ":\n") {
	alert(msg)
	return;
	}

	else 
	{ document.forms.register.submit() }
}

/*******************************************************************
Function: validRadio(formField)
Description: Is a Helper function to checkForm(), checks if radiobuttons are checked.
*******************************************************************/
function validRadio(formField) 
{ 
 var result = true; 
 var radioSelected; 

 for (var i=0; i<formField.length; i++){ 
 if (formField[i].checked) { 
  radioSelected = formField[i].value 
 } 
}

if (!radioSelected)
 { result = false; } 

return result; 
}