/*********************************************** 
* Ajax Includes script- © Dynamic Drive DHTML code library (www.dynamicdrive.com) 
* This notice MUST stay intact for legal use 
***********************************************/ 
//Included file MUST be from the same domain as the page displaying it. 
var rootdomain="http://"+window.location.hostname 
function ajaxinclude(url) { 
var page_request = false 
if (window.XMLHttpRequest) // if Mozilla, Safari etc 
page_request = new XMLHttpRequest() 
else if (window.ActiveXObject){ // if IE 
try { 
page_request = new ActiveXObject("Msxml2.XMLHTTP") 
} 
catch (e){ 
try{ 
page_request = new ActiveXObject("Microsoft.XMLHTTP") 
} 
catch (e){} 
} 
} 
else 
return false 
page_request.open('GET', url, false) //get page synchronously 
page_request.send(null) 
writecontent(page_request) 
} 
function writecontent(page_request){ 
if (window.location.href.indexOf("http")==-1 || page_request.status==200) 
document.write(page_request.responseText) 
} 

if( document.addEventListener ) document.addEventListener( 'DOMContentLoaded', cmxform, false );

function cmxform(){
  // Hide forms
  $( 'form.cmxform' ).hide().end();
  
  // Processing
  $( 'form.cmxform' ).find( 'li/label' ).not( '.nocmx' ).each( function( i ){
    var labelContent = this.innerHTML;
    var labelWidth = document.defaultView.getComputedStyle( this, '' ).getPropertyValue( 'width' );
    var labelSpan = document.createElement( 'span' );
        labelSpan.style.display = 'block';
        labelSpan.style.width = labelWidth;
        labelSpan.innerHTML = labelContent;
    this.style.display = '-moz-inline-box';
    this.innerHTML = null;
    this.appendChild( labelSpan );
  } ).end();
  
  // Show forms
  $( 'form.cmxform' ).show().end();
}


function expandingWindow(website) {
window.open(website,'mywindow',"status = 1, height = 720, width = 780, scrollbars=yes,status=yes" )
}

function validateNumber(field, msg) { 
var mytext = document.getElementById("buildingsum");
if (isNaN(field)) {

	//if ( (parseInt(mytext) != mytext) ) { 
		alert(msg); 
		 
		document.getElementById("buildingsum").select();
		mytext.focus(); 
		mytext.select();
		
		return false; 
	} 
return true; 
}
function validateNumber1(field, msg) { 
var mytext1 = document.getElementById("contentsum");
if (isNaN(field)) {

	//if ( (parseInt(mytext1) != mytext1) ) { 
		alert(msg); 
		 
		document.getElementById("contentsum").select();
		mytext1.focus(); 
		mytext1.select();
		return false; 
	} 
return true; 
}
function validateNumber2(field, msg) { 
var mytext1 = document.getElementById("premium");
if (isNaN(field)) {

	//if ( (parseInt(mytext1) != mytext1) ) { 
		alert(msg); 
		 
		document.getElementById("premium").select();
		mytext1.focus(); 
		mytext1.select();
		return false; 
	} 
return true; 
}
function call(frm) {
var pst = frm.postcode.value;


if (pst == "") { 
alert ("Please Enter your Postcode");
frm.postcode.value = "";
frm.postcode.focus();
return false; 
}

var bsi = frm.buildingsum.value;
if (bsi == "") 
{ 
	bsi = 0; 
} else{
	if (bsi > 500000 || bsi < 35000) { 
		alert ("Enter the Building Insurance amount. the maximum amount is 500,000.00 & minimum amount is 35000");
		frm.buildingsum.value = "";
		frm.buildingsum.focus();
		return false; 
	}
}


var csi = frm.contentsum.value;
if (csi == ""){ 
	csi = 0; 
} else {
	if (csi > 30000 || csi < 1000) { 
		alert ("Enter the Content Insurance amount. the maximum amount is 30,000.00 & minimum amount is 1000");
		frm.contentsum.value = "";
		frm.contentsum.focus();
		return false; 
	}
}


if( bsi == 0 && csi == 0){
	alert("Please write one of Building Insurance amount or Content Insurance amount");
	frm.ans.value = "";
	
	return false;
}

var c = frm.type.value;

if (c == "") { 
alert ("Please select one of the Tenancy Type");
frm.type.focus();
return false; 
}

var x = (parseFloat(bsi)/1000 * c).toFixed(2);
//alert (x);
var y = ((parseFloat(csi)/1000)*5).toFixed(2);
//alert (y);
var val;

if( x > 0 && y >= 0 )
{
	if ( parseFloat(x)+parseFloat(y) <= 100)
	{
		val = 100;
		//alert("total less then 100")
	} else 
	{
		val = parseFloat(x)+parseFloat(y);
		//alert("total more thn 100");
	}

} 
	
if(x <= 0 && y <= 50)
{
	val = 50;
	//alert("use 50");
} 
if(x <= 0 && y > 50)
{
	val = parseFloat(x)+parseFloat(y);
}
	

//alert (parseFloat(val));
var ipt = ((parseFloat(val)/100)*5).toFixed(2);
//alert ("ipt ="+ ipt);
var percent = parseFloat(ipt)+parseFloat(val);
//alert ("percent");
//alert (percent);
//var tot = (parseFloat(x) + parseFloat(y) + parseFloat(percent)).toFixed(2);
var tot = (parseFloat(percent)).toFixed(2);
//alert (tot);
parseFloat(tot); 
frm.ans.value = tot;
frm.proceed.disabled=false;
}
//alert (x);


function dis(f)
{
	f.proceed.disabled=true;
}

function WindowC()
{
expandingWindow('http://quote.touch10.co.uk/OnlineQuoteEngine/productquote.aspx?ac=NzgzNg==&magolzbi=TEhJ');
}

function beater()
{
expandingWindow('quotebeater.php');
}

function validate_form ()
{

    if ( document.frm.NAME.value == "" )
    {
        alert ( "Please fill in the 'Your Name' box." );
		document.frm.NAME.focus();
        return false;
    }
	apos=document.frm.FROM.value.indexOf("@");
	dotpos=document.frm.FROM.value.lastIndexOf(".");
	if (document.frm.FROM.value == "" || apos<1 || dotpos-apos<2)
	{
		alert("Please fix: email");
		document.frm.FROM.focus();
		return false;
	}
	if ( document.frm.COMMENTS.value == "" )
    {
        alert ( "Please fill in the 'Your Message' box." );
		document.frm.COMMENTS.focus();
        return false;
    }
	if(document.frm.w1.checked == true)
	{
			if ( document.frm.tel.value == "" )
			{
				alert ( "Please fill in the 'Your contact' box." );
				document.frm.tel.focus();
				return false;
			}
			if(isNaN(document.frm.tel.value)) {
				alert ( "Please fill Your contact number." );
				document.frm.tel.select();
				document.frm.tel.style.border = '1px #FF0000 solid';
				return false;
			}
			if ( document.frm.interest.selectedIndex == 0 )
			{
				alert ( "Please select your Interested in." );
				document.frm.interest.focus();
				return false;
			}
			if ( document.frm.time.selectedIndex == 0 )
			{
				alert ( "Please select your Time to call." );
				document.frm.time.focus();
				return false;
			}
			return true;
	}
	return true;
}


function validate_rform ()
{
	var pst = document.getElementById('postcde').value;


		if (pst == "") { 
		alert ("Please Enter your Postcode");
		document.getElementById('postcde').focus();
		return false; 
		}
		
		var bsi = document.getElementById('buildingsum').value;
		if (bsi == "") 
		{ 
			bsi = 0; 
		} else{
			if (bsi > 500000 || bsi < 35000) { 
				alert ("Enter the Building Insurance amount. the maximum amount is 500,000.00 & minimum amount is 35000");
				document.getElementById('buildingsum').focus();
				return false; 
			}
		}
		
		
		var csi = document.getElementById('contentsum').value;
		if (csi == ""){ 
			csi = 0; 
		} else {
			if (csi > 30000 || csi < 1000) { 
				alert ("Enter the Content Insurance amount. the maximum amount is 30,000.00 & minimum amount is 1000");
				document.getElementById('contentsum').focus();
				return false; 
			}
		}
		
		
		if( bsi == 0 && csi == 0){
			alert("Please write one of Building Insurance amount or Content Insurance amount");
			document.getElementById('buildingsum').focus();
			return false;
		}
	
	if ( document.getElementById('premium').value == "" )
    {
        alert ( "Please fill Premium" );
		document.getElementById('premium').focus();
        return false;
    }
	            
	if ( isNaN(document.getElementById('premium').value))
    {
        alert ( "Please fill Premium in digits" );
		document.getElementById('premium').select();
		document.getElementById('premium').focus();
        return false;
    }
	return true;
}

function detail_rform ()
{
	if ( document.getElementById('tel').value == "" )
	{
		alert ( "Please fill your contact Number." );
		document.getElementById('tel').focus();
		return false;
	}
	if(!ValidateNo(document.getElementById('tel').value,"1234567890+- ")) 
	{ 
		alert("Please Enter Only Number"); 
		document.getElementById('tel').focus(); 
		document.getElementById('tel').style.border = '1px #FF0000 solid';
		return false; 
	}	
	return true;
}
function ValidateNo(NumStr, String) 
{ 
    for(var Idx=0; Idx<NumStr.length; Idx++) 
    { 
        var Char = NumStr.charAt(Idx); 
        var Match = false; 

        for(var Idx1=0; Idx1<String.length; Idx1++) 
        { 
            if(Char == String.charAt (Idx1)) 
                Match = true; 
        } 

        if (!Match) 
            return false; 
    } 
    return true; 
}