﻿
function SubmitForm(buttonID, e)
{
    
    var key;

         if(window.event)
              key = window.event.keyCode;     //IE
         else
              key = e.which;     //firefox
    
        if (key == 13)
        {
            __doPostBack(buttonID,'');
            //this.document.getElementById(buttonID).click();   
        }    
}



function PrintPdf(companyID, countyID, postcodeID, propertyID, streetID, townID)
{
    var company = document.getElementById(companyID).value;
    var county = document.getElementById(countyID).value;
    var postcode = document.getElementById(postcodeID).value;
    var property = document.getElementById(propertyID).value;
    var street = document.getElementById(streetID).value;
    var town = document.getElementById(townID).value;
    
    if( postcode.length == 0 || street.length == 0 || town.length == 0)
    {
        return false;
    }
    
    var queryString = "";
    if( company.length > 0 )
    {
        queryString = queryString + "company=" + escape(company) + "&";
    }
    if( county.length > 0 )
    {
        queryString = queryString + "county=" + escape(county) + "&";
    }
    if( postcode.length > 0 )
    {
        queryString = queryString + "postcode=" + escape(postcode) + "&";
    }
    if( property.length > 0 )
    {
        queryString = queryString + "property=" + escape(property) + "&";
    }
    if( street.length > 0 )
    {
        queryString = queryString + "street=" + escape(street) + "&";
    }
    if( town.length > 0 )
    {
        queryString = queryString + "town=" + escape(town) + "&";
    }
    queryString = queryString.substring(0, queryString.length - 1 );
    
    window.open('Letters/PrintPDF.aspx?'+queryString, 'NominateCompanyLetter');
}

function swapImage(imageID, imageUrl)
{
    document.getElementById(imageID).src = imageUrl;
}

function RegisterAjax_Clicker()
{

      this.document.getElementById(registerAjaxClicker).click(); 
       
}
function RedirectPage(url)
{
    window.location.href=url;
}
function ResizeOverlay(overlayLayerID)
{
    var layer = document.getElementById(overlayLayerID);
    
    var w = getWindowWidth(); //document.body.scrollWidth;
    var h = getWindowHeight(); //document.body.scrollHeight;
    
    //alert("w : "+w+" h: "+h);
    
    if(layer != null)
    {
        /*alert(layer);
        layer.style.display = 'block';*/
        layer.style.width = w+"px";
        layer.style.height = h+"px";
    }
}

function getWindowWidth()
{
    return Math.max(document.body.scrollWidth, getDocWidth());
    

}

function getDocWidth()
{
    width1 = (self.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || 0);
    
    	if (window.innerHeight && window.scrollMaxY) {// Firefox
		width2 =  (xWithScroll = window.innerWidth + window.scrollMaxX);
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		width2 =  (xWithScroll = document.body.scrollWidth);
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		width2 =  (document.body.offsetWidth);
  	}

    return Math.max(width1, width2);
}
	
function getWindowHeight()
{
	return Math.max(document.body.scrollHeight, getDocHeight());
	

}
function getDocHeight()
{
    height1 = (self.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0);
    
    if (window.innerHeight && window.scrollMaxY) {// Firefox
		height2 = (window.innerHeight + window.scrollMaxY);
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		height2 = (document.body.scrollHeight);
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		height2 = (document.body.offsetHeight);
  	}
  	
  	return Math.max(height1, height2);
}