dojo.require("dijit.Dialog");
dojo.require("dojo.parser");


function getInternetExplorerVersion() {
	var rv = -1; // Return value assumes failure.
	if (navigator.appName == 'Microsoft Internet Explorer') {
		var ua = navigator.userAgent;
		var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
			rv = parseFloat(RegExp.$1);
	}
	return rv;
}

function checkVersion() {
	var msg = "You're not using Windows Internet Explorer.";
	var ver = getInternetExplorerVersion();
	if (ver > -1) {
		if (ver >= 8.0)
			msg = "You're using a recent copy of Windows Internet Explorer."
		else
			msg = "You should upgrade your copy of Windows Internet Explorer.";
	}
	alert(msg);
}

	
function calcHeight(iframe_name)
{
	var getIE = getInternetExplorerVersion();
	var the_height;
  //find the height of the internal page
  if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
	  the_height = document.getElementById(iframe_name).contentDocument.body.scrollHeight;
	  the_height = (the_height + 70);  
  }else{
	  the_height = document.getElementById(iframe_name).contentWindow.document.body.scrollHeight;			
  		if(getIE > 7){
		  the_height = (the_height + 70);  
		}else{
			the_height = (the_height + 60);
		}
 }
 	console.log("height: " + the_height);
	document.getElementById(iframe_name).height = the_height;
}

function removeQuotes(tabName) {
    tabName = tabName.split("'").join("&#39;");
    tabName = tabName.split('"').join("&#39;");
	tabName = tabName.split("\"").join("&#39;");
	tabName = tabName.split("&quot;").join("&#39;");
    return tabName;
}

var dialogView;
function showActualSize(imgloc, imgname){
//	imgname = removeQuotes(imgname);
//	dialogView = new dijit.Dialog({
//				  title: "View Full Size Image",
//				  style: "width: auto; text-align: center",
//				  content: "<img src='" + imgloc + "' alt='"+ imgname +"' /><br><input type='button' value='Close' style='text-align: center' onclick='closeActualSize();'/>"});
//	dialogView.startup();
//	dialogView.show();
	window.open(imgloc);
}

function closeActualSize(){
	dialogView.hide();
}