function JF_ErrHandle(as_name, as_label, as_err) {
 alert(as_err);
 as_name.focus();
 return; 
}
function JF_ChkNotNull(as_name, as_label)
{	
	js_val = Trim(as_name.value);
	js_err = 'N';
	if (js_val == "" || js_val== null ) 
	{
		js_err= as_label + ' must  be entered.';
	}
	else 
	{
		for(var i=0;i<js_val.length;i++) 
		if (js_val.substring(i,i+1) != ' ') break;
		if (i>=js_val.length) 
		{
			js_err= as_label + ' cannot be spaces.'; 
		}
	}
	if (js_err != 'N') 
	{
		JF_ErrHandle(as_name, as_label, js_err) ;
		return false;
	}
	return true;
}
function Trim(str)
/***
        PURPOSE: Remove trailing and leading blanks from our string.
        IN: str - the string we want to Trim

        RETVAL: A Trimmed string!
***/
{
    trim_str = RTrim(LTrim(str));            
    return trim_str;
}
function LTrim(str)
/***
        PURPOSE: Remove leading blanks from our string.
        IN: str - the string we want to LTrim

        RETVAL: An LTrimmed string!
***/
{
        var whitespace = new String(" \t\n\r");

        var s = new String(str);

        if (whitespace.indexOf(s.charAt(0)) != -1) {
            // We have a string with leading blank(s)...

            var j=0, i = s.length;

            // Iterate from the far left of string until we
            // don't have any more whitespace...
            while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                j++;


            // Get the substring from the first non-whitespace
            // character to the end of the string...
            s = s.substring(j, i);
        }

        return s;
}
 function RTrim(str)
/***
        PURPOSE: Remove trailing blanks from our string.
        IN: str - the string we want to RTrim

        RETVAL: An RTrimmed string!
***/
{
        // We don't want to trip JUST spaces, but also tabs,
        // line feeds, etc.  Add anything else you want to
        // "trim" here in Whitespace
        var whitespace = new String(" \t\n\r");

        var s = new String(str);

        if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
            // We have a string with trailing blank(s)...

            var i = s.length - 1;       // Get length of string

            // Iterate from the far right of string until we
            // don't have any more whitespace...
            while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
                i--;


            // Get the substring from the front of the string to
            // where the last non-whitespace character is...
            s = s.substring(0, i+1);
        }

        return s;
} 
function JF_ChkValidEmail(as_name,as_label) 
{
	js_val = Trim(as_name.value);

	vs_error='N';
	if ((js_val != '') && (js_val != null)) 
	{
		for (var i =0; i < js_val.length; i++) 
		if (!(js_val.substring(i,i+1) >= "a"  && js_val.substring(i,i+1) <= "z"))	
		if (!(js_val.substring(i,i+1) >= "A"  && js_val.substring(i,i+1) <= "Z"))	
		if (!(js_val.substring(i,i+1) >= "0"  && js_val.substring(i,i+1) <= "9"))	
		if (!(js_val.substring(i,i+1) == "."  || js_val.substring(i,i+1) == "@" || js_val.substring(i,i+1) == "-" || js_val.substring(i,i+1) == "_" || js_val.substring(i,i+1) == "%" ))
		{
			js_err= as_label + ' contains invalid characters.'; 
			JF_ErrHandle(as_name, as_label, js_err) ;
			return false;
		}
		if (js_val.length <5 )vs_error='Y';
		if (js_val.indexOf('@') == -1) vs_error='Y';
		if (js_val.indexOf('.') == -1) vs_error='Y';
		js_first=js_val.substring(0,1);
		js_last=js_val.substring(js_val.length-1);
		if (js_first=='@' || js_last=='@' || js_first=='.' || js_last=='.') 
		{
			vs_error='Y';
		}
		jl_pos = js_val.indexOf('@');
		js_next = js_val.substring(jl_pos+1,jl_pos+2);
		js_prev = js_val.substring(jl_pos-1,jl_pos);
		if ((js_next == '.') || (js_prev == '.'))
		{
			vs_error='Y';
		}
		if (vs_error == 'Y') 
		{
			js_err= 'Invalid ' + as_label; 
			JF_ErrHandle(as_name, as_label, js_err) ;
			return false;
		}
	}
	return true;
}
function JF_ReplaceQuotes(as_name,  as_label)
{
	js_val = as_name.value;
	js_val1 = '';
	for(var i=0;i<js_val.length;i++) 
	{
		if (js_val.substring(i,i+1) == '"') 
		{
		js_val1 += '&quot;';
		}
		else
		js_val1 += js_val.substring(i,i+1);
	}
	as_name.value = js_val1;
	return true;
}

function JF_SendAddReq()
{
	if (!JF_ChkNotNull(window.document.form_conf.sle_Vname,'Venue Name')) return ;
	if (!JF_ChkNotNull(window.document.form_conf.sle_Cname,'Contact Person')) return ;
	if (!JF_ChkNotNull(window.document.form_conf.sle_Gtel,'Telephone')) return ;
	if (!JF_ChkNotNull(window.document.form_conf.sle_GEmail,'Email')) return ;
	if (!JF_ChkValidEmail(window.document.form_conf.sle_GEmail,'Email')) return ;
	
	JF_ReplaceQuotes(window.document.form_conf.sle_Vname,'');
	JF_ReplaceQuotes(window.document.form_conf.sle_Cname,'');
	JF_ReplaceQuotes(window.document.form_conf.sle_Gtel,'');
	JF_ReplaceQuotes(window.document.form_conf.sle_GEmail,'');
	JF_ReplaceQuotes(window.document.form_conf.sle_Address,'');
	
	jsrsExecute("Conf_resolution.asp", JF_retvenueadd, "SendAddVenueReq", Array(document.form_conf.sle_Vname.value, document.form_conf.sle_Cname.value, document.form_conf.sle_Gtel.value, document.form_conf.sle_GEmail.value,document.form_conf.sle_Address.value));
}
function JF_retvenueadd(returnstring)
{
	if(returnstring == 'Y')
	{
		window.document.form_conf.sle_Vname.value = '';
		window.document.form_conf.sle_Cname.value = '';
		window.document.form_conf.sle_Gtel.value = '';
		window.document.form_conf.sle_GEmail.value = '';
		window.document.form_conf.sle_Address.value = '';
		
		msgWindow3=window.open("conf_callbackthanks.htm","displayWindow","menubar=no,scrollbars=no,status=no,width=400,height=250,top=250,left=450")
		if (msgWindow3.opener == null) msgWindow3.opener = self;
		msgWindow3.focus();
		
		//alert('Thank you for your Request... We will get back to you soon..!!');
		//window.close();
		return false;
	}
}
function JF_Sendmail()
{

	if (!JF_ChkNotNull(window.document.form_conf.sle_Gname,'Your Name')) return ;
	if (!JF_ChkNotNull(window.document.form_conf.sle_Gtel,'Your Telephone')) return ;
	if (!JF_ChkNotNull(window.document.form_conf.sle_GEmail,'Your Email')) return ;
	if (!JF_ChkValidEmail(window.document.form_conf.sle_GEmail,'Email')) return ;
	
	JF_ReplaceQuotes(window.document.form_conf.sle_Gname,'');
	JF_ReplaceQuotes(window.document.form_conf.sle_Gtel,'');
	JF_ReplaceQuotes(window.document.form_conf.sle_GEmail,'');
	JF_ReplaceQuotes(window.document.form_conf.sle_OtherInfo,'');
	
	jsrsExecute("Conf_resolution.asp", JF_retfunction, "SendCallBackRequest", Array(document.form_conf.sle_Gname.value,document.form_conf.sle_Gtel.value,document.form_conf.sle_GEmail.value,document.form_conf.sle_OtherInfo.value));
}
function JF_retfunction(returnstring)
{
	if(returnstring == 'Y')
	{
		window.document.form_conf.sle_Gname.value = '';
		window.document.form_conf.sle_Gtel.value = '';
		window.document.form_conf.sle_GEmail.value = '';
		window.document.form_conf.sle_OtherInfo.value = '';
		
		msgWindow3=window.open("conf_callbackthanks.htm","displayWindow","menubar=no,scrollbars=no,status=no,width=400,height=250,top=250,left=450")
		if (msgWindow3.opener == null) msgWindow3.opener = self;
		msgWindow3.focus();
		
		//alert('Thank you for your enquiry... We will get back to you soon..!!');
		return false;
	}
}

function JF_subSrch()
{
	if(window.document.form_conf.hid_page) window.document.form_conf.hid_page.value = '';
	window.document.form_conf.action = 'top-uk-venues.asp';
	window.document.form_conf.submit();
}

function JF_getlisted()
{
msgWindow2=window.open("conf_getlisted.asp","displayWindow","menubar=no,scrollbars=no,status=no,width=250,height=300,top=200,left=450")
if (msgWindow2.opener == null) msgWindow2.opener = self;
msgWindow2.focus();
}

//Venue Detail Page 
function JF_CallPop(as_imgname,as_est_cd,as_hotel_nam,as_inc)
{

if(as_imgname.indexOf("_t")>0)
{
splitImage=as_imgname.split("_t")
as_r_img=splitImage[0] + splitImage[1];
}
else
{
as_r_img=as_imgname;
}

msgWindow=window.open("conf_hotel_popup.asp?hid_img_nam="+as_r_img+"&hid_est_code="+as_est_cd+"&hid_hotel_name="+as_hotel_nam+"&hid_img_inc="+as_inc,"displayWindow","menubar=no,scrollbars=no,status=no,width=550,height=600,top=1,left=1")
if (msgWindow.opener == null) msgWindow.opener = self;
msgWindow.focus() 

}
function JF_Reqformdetail()
{
	msgWindow1=window.open("conf_enquiry_form.asp?venu_id="+document.form_conf.hid_venue_id.value+"&venu_name="+document.form_conf.hid_venue_name.value,"displayWindow","menubar=no,scrollbars=yes,status=no,width=1000,height=720,top=0,left=0")
if (msgWindow1.opener == null) msgWindow1.opener = self;
msgWindow1.focus()
}
function Jf_imagemap(id)
{
//window.open("bhrc_hotel_popup.asp?hid_img_nam="+as_r_img+"&hid_est_code="+as_est_cd+"&hid_hotel_name="+as_hotel_nam+"&hid_img_inc="+as_inc,"displayWindow","toolbar=no, titlebar=yes, fullscreen=no,location=0,directories=no,menubar=no,scrollbars=no,status=no,width=550,height=600,top=1,left=1")
var msgWindow=window.open("conf_map_popup.asp?seqmap="+id,"displayWindow","height=700, left=305, menubar=no,resizable=yes,scrollbars=yes, status=no, top=0, width=700")
if (msgWindow.opener == null) msgWindow.opener =top;
 msgWindow.focus();
}