function openAdmin(address) {
        window.open(address,"admin","resizable=yes,scrollbars=yes,width=450,height=650,top=50%,left=50%")
}

function condelete(address) {
	var input_box = confirm("Are you sure you want to permanently delete this photo from the database?");
		if (input_box==true) {
			openAdmin(address);
		}
	}

var remove_rectangle = function() {
    var lnks = document.links;
    if (lnks) {
        for (var i = 0; i < lnks.length; i++) {
            lnks[i].onmousedown = function() {
                this.blur();
                return false;
            }
        }
    }
}

window.onload = function() {
    remove_rectangle();
}

function charLimit(fieldName, maxChar) {
	// get & make variables
	var txtV = document.getElementById(fieldName).value;
	var txtL = txtV.length;
	var txtF1 = "(";
	var txtF2 = " remaining)";
	document.getElementById('charslimit').innerHTML = txtF1+(maxChar-txtL)+txtF2;
	
	// if length exceeded maximum limit
	if (txtL > maxChar) {		
		txtN = txtV.substring(0, maxChar);
		document.getElementById(fieldName).value = txtN;
		alert("You have exceeded the 300 characters allowed for comments");
	}
	//alert("hello");
}

function subTabSwitch() {
if (document.getElementById('sub_tab').className == 'close') {
	document.getElementById('sub_tab').className = 'open';
} else {
	document.getElementById('sub_tab').className = 'close';
}}

function imgShow(image, type) {
if (type == 'on') {
	document.getElementById(image).style.display = 'block';
} else {
	document.getElementById(image).style.display = 'none';
}}

function hashCheck() {
var hashIndex = document.URL.indexOf('#');

	if (hashIndex != -1) { 
	var hashValue = document.URL.substring(hashIndex+1, document.URL.length);
		if ((hashValue == "comments") || (hashValue == "share")) {
			document.getElementById('sub_tab').className = "open";
			if (hashValue == "comments") {
				document.getElementById('addname').focus();
				} else { 
				document.getElementById('share_name1').focus();
			}
		} 
	} else {
		document.getElementById('sub_tab').className = "close";
	}
}

function touchNote(photoNum) {
	a = photoNum.toString();
	numlen = a.length;
	if(numlen == 1) {b = "00"+a;} else if(numlen == 2) {b = "0"+a;}
	tnURL = 'http://www.touchnote.com/photo/simpleUpload/?refid=123&imgsrc=http://www.someoneoncetoldme.com/photos/hi_res/'+b+'.jpg';
	alert(tnURL);
	window.open(tnURL);
}