if((navigator.userAgent.indexOf("Mac")>-1)&&(navigator.appName=="Microsoft Internet Explorer"))ie_mac = 1;
else ie_mac = 0;

//to get the real size of the browser on the screen ( cross_browser )
function getSize(prefix){
	if(prefix == null){
		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}
	}
	else{
		if (self.innerHeight) {	// all except Explorer
			windowWidth = parent.self.innerWidth;
			windowHeight = parent.self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = parent.document.documentElement.clientWidth;
			windowHeight = parent.document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = parent.document.body.clientWidth;
			windowHeight = parent.document.body.clientHeight;
		}
	}
	return windowWidth, windowHeight;
}

//clearScreen : to remove the frame and the overlay when the user clicks on the closing cross
function clearScreen(){
	parent.document.body.style.overflow = 'scroll';// to re-enable the scrolling on the main page
	parent.document.body.removeChild(parent.document.getElementById('overlay_img'));
	parent.document.body.removeChild(parent.document.getElementById('iframe_success'));
}

//magnify_state : function that will create the grey transparent overlay and the iframe containing the success stories
function magnify_state(state,map_type){
	document.body.style.overflow = 'hidden';
	getSize();
	//creation of the grey transparent overlay on the screen
	var over = document.createElement('div');
	over.setAttribute('id','overlay_img');
	over.style.display = 'block';
	over.style.backgroundColor = '#000';
	over.style.width = '100%';
	var safariOld = parseInt(navigator.appVersion.toLowerCase().split('safari/')[1])<500;//detection of old versions of Safari
	if(safariOld)over.style.height = '300%';
	else over.style.height = '100%';
	over.style.position = 'absolute';
	over.style.top = document.body.scrollTop+'px';
	over.style.left = 0;
	over.style.filter = 'alpha(opacity=60)';
	over.style.opacity = .60;
	over.onclick = function(){clearScreen();};
	var locFolder = ((map_type=='math')?"/highered/math":"/k12");
	//creation of the iframe containing the state success stories
	if(ie_mac == 0){
		var iframe = document.createElement('iframe');
		iframe.src = locFolder+'/map_popup?_form_=true&map_type='+map_type+'&cmscache=state_and_type&state_and_type='+state+'*'+map_type+'&state='+state;
		iframe.style.border = 'none';
		iframe.style.zIndex = 10001;
		iframe.style.position = 'absolute';
		iframe.id = 'iframe_success';
		iframe.name = 'iframe_success';
		if(navigator.appName == "Microsoft Internet Explorer") iframe.style.width = '604px';
		else iframe.style.width = '608px';
		if(navigator.appName == "Microsoft Internet Explorer") iframe.style.height = '374px';
		else iframe.style.height = '384px';
		iframe.style.left = (windowWidth - 600)/2+'px';
		iframe.style.top =  document.body.scrollTop+(windowHeight - 400)/2+'px';
		iframe.scrolling = 'no';
		iframe.style.filter = 'alpha(opacity=100)';
		iframe.style.opacity = 1.0;
		document.body.appendChild(over);
		document.body.appendChild(iframe);
	}
	else{
		var popup_left = Math.round((windowWidth-600)/2);
		var popup_top = Math.round((windowHeight-374)/2);
		mysuccess = window.open(locFolder+'/map_popup?_form_=true&map_type='+map_type+'&cmscache=state&state='+state,'mysuccess','location=0,directories=no,status=1,resizable=no,scrollbars=0,width=600,height=374');
		mysuccess.moveTo(popup_left, popup_top);
	}
}

//pop_impstrat : to display the correct implementation strategy popup if needed
function pop_impstrat(nature_impstrat, type_impstrat, page_impstrat){
	getSize('inframe');
	var popup_left = Math.round((windowWidth-800)/2);
	var popup_top = Math.round((windowHeight-600)/2);
	if(nature_impstrat == 'k12') nature_impstrat = '/k12/implementations';
	else if(nature_impstrat == 'math') nature_impstrat = '/highered/math/implementations';
	else nature_impstrat = '/homeschool/implementation_strategies';
	myframe = window.open(nature_impstrat+"/popup?_form_=true&parse_list="+type_impstrat+"*"+page_impstrat+"&parse_request=true&cmscache=parse_list:parse_request","myframe","location=0,directories=no,status=1,resizable=yes,scrollbars=1,width=800,height=600");
	myframe.moveTo(popup_left, popup_top);
}

function div_print(){
	getSize('inframe')
	var myHTML = document.getElementById('popup_success').innerHTML;
	succ_print = window.open('','succ_print','location=0,status=0,directorie=no,resizable=no,scrollbars=0,width=800,height=600');
	popup_left = Math.round((windowWidth-800)/2);
	popup_top = Math.round((windowHeight-600)/2);
	succ_print.moveTo(popup_left, popup_top);
	succ_print.document.open();
	succ_print.document.write('<html><body onload="window.print()">'+myHTML+'<script language="Javascript">for(i=0;i<document.getElementsByTagName("img").length;i++){document.getElementsByTagName("img")[i].style.display = "none";}</script></body></html>');
	succ_print.document.close();
	setTimeout(function(){succ_print.close();},1000);
}
