function popupwin(str_url,h,w,scrolling) {
	vars = "height="+h+",width="+w+",left="+(screen.width/2-(w/2))+",top="+(screen.height/2-(h/2))+",scrollbars="+ scrolling +",toolbar=no,status=no"
	focus_win = window.open(str_url,'newwin',vars)
	focus_win.window.focus()
	}



function verify_email(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){return false}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) {return false}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) {return false}
	if (str.indexOf(at,(lat+1))!=-1) {return false}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) {return false}
	if (str.indexOf(dot,(lat+2))==-1) {return false}
	if (str.indexOf(" ")!=-1) {return false}
	return true					
	}

function ensureNumeric(strString,mini,maxi)
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;
   if (strString.length < mini | strString.length > maxi) return false;
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function check_form(str_form,str_args) { // v0 copyright Andrew Watson Paligap 2004 (CALL) onClick="check_form('frm_subscribe','str_name|t|1|You have not entered your name.,str_email|e|1|You have entered an invalid e-mail address.');return document.check_form_return;"
	var arr_args = str_args.split(",")
	str_error_message = ""
	for(i=0;i<arr_args.length;i++) {
		var arr_this_element = arr_args[i].split("|")
		str_field = arr_this_element[0]
		str_type = arr_this_element[1]
		bln_required = arr_this_element[2]
		str_message = arr_this_element[3]
		this_value = eval("document." + str_form + "." + str_field + ".value")
		this_value = this_value.replace(" ","")
			if (str_type == "t") { //Check String
				if (bln_required==1) {
					if (this_value=='') {str_error_message = str_error_message + str_message + "\n\n"}
				}
			} else if (str_type == "e") { //Check Email
				if (bln_required==1) {
					if (this_value==''||!verify_email(this_value)) {str_error_message = str_error_message + str_message + "\n\n"}
				} else {
					if (this_value!=''&&!verify_email(this_value)) {str_error_message = str_error_message + str_message + "\n\n"}
				}
			} else if (str_type == "n") { //Check Numeric
				if (bln_required==1) {
					if (this_value==''||isNaN(this_value)) {str_error_message = str_error_message + str_message + "\n\n"}
				} else {
					if (this_value!=''&&isNaN(this_value)) {str_error_message = str_error_message + str_message + "\n\n"}
				}
			} else if (str_type == "d") { //Check Date
				if (bln_required==1) {
					if (this_value==''||!verify_date(this_value)) {str_error_message = str_error_message + str_message + "\n\n"}
				} else {
					if (this_value!=''&&!verify_date(this_value)) {str_error_message = str_error_message + str_message + "\n\n"}
				}
			}
		}
		if (str_error_message!="") {
			str_error_message = "Incomplete Form Information!                              \n________________________\n\n" + str_error_message
			alert(str_error_message)
			document.check_form_return = false
		} else {
			document.check_form_return = true
			//eval("document.forms." + str_form + ".submit();")
		}
	}
	
function popUp(){// v1.3
// Copyright 2002, Marja Ribbers-de Vroed, FlevOOware (www.flevooware.nl/dreamweaver/)
var v1=arguments,v2=v1[2].split(","),v3=(v1.length>3)?v1[3]:false,v4=(v1.length>4)?parseInt(v1[4]):0,v5=(v1.length>5)?parseInt(v1[5]):0,v6,v7=0,v8,v9,v10,v11,v12,v13,v14,v15,v16,v17,v18;if (v4>1){v10=screen.width;for (v6=0;v6<v2.length;v6++){v18=v2[v6].split("=");if (v18[0]=="width"){v8=parseInt(v18[1]);}if (v18[0]=="left"){v9=parseInt(v18[1]);v11=v6;}}if (v4==2){v7=(v10-v8)/2;v11=v2.length;}else if (v4==3){v7=v10-v8-v9;}v2[v11]="left="+v7;}if (v5>1){v14=screen.height;for (v6=0;v6<v2.length;v6++){v18=v2[v6].split("=");if (v18[0]=="height"){v12=parseInt(v18[1]);}if (v18[0]=="top"){v13=parseInt(v18[1]);v15=v6;}}if (v5==2){v7=(v14-v12)/2;v15=v2.length;}else if (v5==3){v7=v14-v12-v13;}v2[v15]="top="+v7;}v16=v2.join(",");v17=window.open(v1[0],v1[1],v16);if (v3){v17.focus();}document.MM_returnValue=false;
}	


        function check_form1(){
        missinginfo = "";
        if (document.frmEditEvents.str_title.value == 0) {
        missinginfo += "\n     -  Event Title";
        }

        if (document.frmEditEvents.str_long_description.value == 0) {
        missinginfo += "\n     -  Event long Description";
        }
        
        if (document.frmEditEvents.str_address_line1.value == 0) {
        missinginfo += "\n     -  Event Address";
        }
        
        if (document.frmEditEvents.int_location.value == 0) {
        missinginfo += "\n     -  Event Location";
        }
        
        if (document.frmEditEvents.str_Postcode.value == 0) {
        missinginfo += "\n     -  Event PostCode";
        }
        
        if (document.frmEditEvents.dat_start_event.value == 0) {
        missinginfo += "\n     -  Event Start Date";
        }
        
        if (document.frmEditEvents.dat_end_event.value != 0){
        if (document.frmEditEvents.dat_end_event.value < document.frmEditEvents.dat_start_event.value) {
        missinginfo += "\n     -  Event End Date is not correct";
        }
        }
        
        if (document.frmEditEvents.dat_end_time_h.value < document.frmEditEvents.dat_start_time_h.value) {
        missinginfo += "\n     -  Event End Time is not correct";
        }
        
        if (document.frmEditEvents.str_contact_name.value == 0) {
        missinginfo += "\n     -  Event Contact Name";
        }

        str_image=document.frmEditEvents.str_image.value.split(".");
        if(str_image!=""){
        str_image="."+str_image[str_image.length-1];
        str_image=str_image.toLowerCase(); 
        if (str_image==".jpg" || str_image==".jpeg" || str_image==".gif" || str_image==".png") {
        }
        else{
        missinginfo += "\n     -  Image File not a permitted type";
        }
        }

        str_file=document.frmEditEvents.str_file.value.split(".");
        if(str_file!=""){
        str_file="."+str_file[str_file.length-1];
        str_file=str_file.toLowerCase(); 
        if (str_file==".zip" || str_file==".pdf" ) {
        }
        else{
        missinginfo += "\n     -  file not a permitted type";
        }
        }


        if (missinginfo != "") {
        missinginfo ="_____________________________\n" +
        "You failed to correctly fill in your:\n" +
        missinginfo + "\n_____________________________" +
        "\nPlease re-enter and submit again!";
        alert(missinginfo);
        return false;
        }

        else
        return true;
        }
       