var ad_timer;
var iframe_url;
function detectsubmit(i){
	//if the url changes to something -- thanks -- then an add has been submited
	obj = MM_findObj('school');
	//lets get the url//
	//alert(obj.src);

	iframe_url = obj.src;

	// if(iframe_url.match("scholar_redirect")){
	// 
	// 	if(!i){
	// 		ad_timer = ad_timer ? clearTimeout(ad_timer):'';
	// 		document.scholarform.leadsubmit.value = 1;
	// 	//	document.scholarform.submit();
	// 		return true;
	// 	}else{
	// 		document.adtrack.lead_submit.value = 1;
	// 		//document.adtrack.submit();
	// 		nothanks(1);
	// 	}
	// }else{
	// 	ad_timer = setTimeout('detectsubmit('+i+')', 50);
	// }
}

function showhidead(i){
	/* SHOW AD */
	if(i == true)
	{
		height = getPageSize('h');
		width = getPageSize('w');
		obj = MM_findObj('school');
		/*
		obj = MM_findObj('ad');
		ad_layerObj = MM_findObj('ad_layer2');
		*/
		ad_layerObj = MM_findObj('school_layer2');
		height = height - 50;
		adtracksubmit();
		obj.style.height = height+'px';
		ad_layerObj.style.top = 0+'px';
		
		$('#school').attr('src',$('#ad_url').val());
		
		scroll(0,0);

		return false;
	}else{

		/* DON'T SHOW AD */
		return true;
	}

	return;

}


function showIframe(){
		height = getPageSize('h');
		width = getPageSize('w');
		obj = MM_findObj('ad');
		ad_layerObj = MM_findObj('ad_layer2');
		height = height - 50;
		obj.style.height = height+'px';
		ad_layerObj.style.top = 0+'px';

		scroll(0,0);
	return;

}
function showInterstitial(x,y){
		height = getPageSize('h');
		width = getPageSize('w');
		obj = MM_findObj(y);
		ad_layerObj = MM_findObj(x);
		height = height - 50;
		obj.style.height = height+'px';
		ad_layerObj.style.top = 0+'px';

		scroll(0,0);
	return;

}
function closeIframeOLD()
{
	ad_layerObj.style.top = 3000+'px';

}
function closeIframe(x)
{
	obj = parent.document.getElementById(x);
	obj.style.top = -3000 + 'px';
	/* obj.style.display="none"; */

}


function adtracksubmit(){
	document.adtrack.submit();//ad tracking//
	return true;
}



function nothanks(i){

	if(!i){
		document.scholarform.submit();
		return true;
	}else{
		ad_layerObj = MM_findObj('ad_layer2');
		ad_layerObj.style.top = -7000+'px';
	}

}



function getPageSize(i) {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

	if(i=='h'){
		return myHeight;
	}else{
		return myWidth;
	}
	//window.alert( 'Width = ' + myWidth );
	//window.alert( 'Height = ' + myHeight );
}
