﻿// JavaScript Document

function showPopup(iname, w, h, popupimage){
	if(!popupimage) {
		var popupimage = 'image';
	}

	$('overlayColour').style.display = 'block';

	document.getElementById("popBox").style.width = Number(w) + Number(24) + 'px';
	document.getElementById("topMidBrace").style.width = Number(w) + 'px';
	document.getElementById("botMidBrace").style.width = Number(w) + 'px';

	document.getElementById("popBox").style.left = ((document.body.clientWidth - w)/2) + 'px';

	var scrollY = 0;
    if (document.documentElement && document.documentElement.scrollTop) {
        scrollY = document.documentElement.scrollTop;
    } else if (document.body && document.body.scrollTop) {
        scrollY = document.body.scrollTop;
    } else if (window.pageYOffset) {
        scrollY = window.pageYOffset;
    } else if (window.scrollY) {
        scrollY = window.scrollY;
    }

	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(scrollY){
		document.getElementById("popBox").style.top = ((myHeight - (Number(h) + Number(24)))/2 + scrollY) + 'px';

	}else{
		//Need a ccheck to make sure that the image fits on the screen.
		if(myHeight < (Number(h) + Number(24))){
			document.getElementById("popBox").style.top = Number(24) + 'px';
		}else{
			document.getElementById("popBox").style.top = ((myHeight - (Number(h) + Number(24)))/2 + scrollY) + 'px';
		}
	}

	if(popupimage == 'image'){
		$('swapFrame').update('<img src="' + iname + '" style="border:1px solid #E7E7E5;" />');
	}else{
		$('swapFrame').update(iname);
	}
	$('popBox').show();
}

function showPublishForm(w, h){

	$('overlayColour').style.display = 'block';

	document.getElementById("addPublisher").style.width = Number(w) + Number(24) + 'px';
	document.getElementById("topMidBrace2").style.width = Number(w) + 'px';
	document.getElementById("botMidBrace2").style.width = Number(w) + 'px';

	document.getElementById("addPublisher").style.left = ((document.body.clientWidth - w)/2) + 'px';

	var scrollY = 0;
    if (document.documentElement && document.documentElement.scrollTop) {
        scrollY = document.documentElement.scrollTop;
    } else if (document.body && document.body.scrollTop) {
        scrollY = document.body.scrollTop;
    } else if (window.pageYOffset) {
        scrollY = window.pageYOffset;
    } else if (window.scrollY) {
        scrollY = window.scrollY;
    }

	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(scrollY){
		document.getElementById("addPublisher").style.top = ((myHeight - (Number(h) + Number(24)))/2 + scrollY) + 'px';

	}else{
		//Need a ccheck to make sure that the image fits on the screen.
		if(myHeight < (Number(h) + Number(24))){
			document.getElementById("addPublisher").style.top = Number(24) + 'px';
		}else{
			document.getElementById("addPublisher").style.top = ((myHeight - (Number(h) + Number(24)))/2 + scrollY) + 'px';
		}
	}

	$('addPublisher').show();
}

function hideBox( s_boxName ){
	$(s_boxName).hide();
	$('overlayColour').hide();
}
