function showElement(id) {
		document.getElementById(id).style.display="block";
}
function hideElement(id) {
		document.getElementById(id).style.display="none";
}
function toggleElement(id) {
	e = document.getElementById(id);
	if (e.style.display=="none") {
		e.style.display="block";
	} else {
		e.style.display="none";
	}
}
function goBack() {
	history.go(-1);
}
function showExtrasWhen(val, targetval, idtoshow) {
	if (val==targetval) {
		showElement(idtoshow);
	} else {
		hideElement(idtoshow);
	}
}
function setLargeImage(filename, telegram_name) {
		document.getElementById("largeimage").src="/images/"+filename;
		document.getElementById("style").value=telegram_name;
}
function clearvalue(el, check) {
		if (el.value==check) {
			el.value="";
		}
		el.className="";
}
function restorevalue(el, defaultV) {
		if (! el.value ) {
            el.value= defaultV
            el.className="defaultfield";
        }
}

function checkrows(textarea,limit){
	var val=textarea.value.replace(/\r/g,'').split('\n');
	if(val.length>limit){
		alert('You can not enter\nmore than '+limit+' lines');
		textarea.value=val.slice(0,-1).join('\n')
	}
}
function showDeliveryTypeNotes(selectElement) {

    var notesArea = document.getElementById("deliveryTypeNotesArea")

    var divs = notesArea.getElementsByTagName("div");

    for ( var i = 0; i < divs.length; i++  )
    {
        if ( divs[i].id && divs[i].id.match( '^DT_.+' ) )
        {
            hideElement( divs[i].id );
        }
    }
    showElement( 'DT_' + selectElement.options[ selectElement.selectedIndex ].value );
}

function postcodeSearch(suburb,state)
{
    // http://www1.auspost.com.au/postcodes/index.asp?Locality=NORTH%20RYDE&sub=1&State=&Postcode=&submit1=Search

    var URL = 'http://www1.auspost.com.au/postcodes/index.asp?Locality=' + window.encodeURI( suburb ) +
              '&sub=1&State=' + window.encodeURI( state ) + '&Postcode=&submit1=Search';

    window.open(URL,"new");
}
function verisign()
{

    window.open('https://seal.verisign.com/splash?form_file=fdf/splash.fdf&type=GOLD&sealid=1&dn=TELEGRAM.AUSPOST.COM.AU&lang=en','_blank');
}

function checkCharCount(e) {
	if (e.value.length > 1000) {
		alert('You have reached the maximum of 1000 characters');
		e.value = e.value.substring(0,1000);
	}
}


