
// example .. <a href="url" onclick="return openPopup(this.href,'small','pdf')">show pdf</a>
//
// url - required :: this will normally be the href of the <a> tag, use 'this.href' in the html
// size - optional :: this can be one of 3 different set sizes. 'small', 'medium' and 'large' - all need to be passed as a string.
// 					If the string does not match any of constants, and no name is given, the string passed is used for the name.
// name - optional :: this is just a string, use it to allow a link to open in an already open popup (with the same name).
//

function openPopup(url,size,name,secure) {
	//alert(url)
	var a = arguments;
	// if no parameters are given
	if (!url) return false;
	// if no name parameter is given
	if (!name) name = "win"+Math.round(Math.random()*999);
	// check the size parameter
	if (!size) {var sizeStr = "width=310,height=455"; size="medium";}
		else switch(size) {
			case "small" : var sizeStr = "width=310,height=295"; break;
			case "medium" : var sizeStr = "width=310,height=455"; break;
			case "large" : var sizeStr = "width=630,height=455"; break;
			case "morningstar" : var sizeStr = "width=758,height=580"; break;
			case "finex" : var sizeStr = "width=530,height=560"; break;
			case "rates" : var sizeStr = "width=768,height=590"; break;
			case "slac_app" : var sizeStr = "width=750,height=600"; break;
			case "product_comparison" : var sizeStr = "width=800,height=600"; break;
			case "lps" : var sizeStr = "width=800,height=600"; break;
			default : var sizeStr = "width=750,height=600";
		}

	// find anchor ref

	var anchor = "";
	if(url) {

		var pos = url.indexOf("#");
		if(pos != -1) {
			anchor = url.substring(pos);
			url = url.substring(0, pos);
		}

		if(url.indexOf("?") != -1){
			sepChar = "&"
		}
		else{
			sepChar = "?"
		}
	}





	if(!secure){
		secure = "no"
	}
	else{secure = "yes"}


	// open the window

window.open(url+sepChar+'size='+size+anchor,name,"directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status="+ secure +",toolbar=no,"+sizeStr);
	// this returns false so that the href is not processed in the original <a> tag.
	return false;
}


/*open pdfs*/
function openPdf(url,name) {

	window.open(url,name,"width=710,height=650,resizable=yes,scrollbars=no");
	// this returns false so that the href is not processed in the original <a> tag.
	return false;
}

//function openPdf(url,name) {
//
//	window.open(url,name,"width=710,height=650,directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
	// this returns false so that the href is not processed in the original <a> tag.
//	return false;
//}


function openBlankWindow(url,name,width,height){
	// if no width is passed in
	if(!width){ width = "800";}
	// if no height is passed in
	if(!height){ height = "600";}

	// if no name parameter is given
	if (!name || name == "") {name = "win"+Math.round(Math.random()*999);}

	window.open(url,name,'width='+ width +',height='+ height +',directories=yes,location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes');

	return false;

}






//this function hides the image buttom and replaces it with a dummy
//Cameron Milne Saturday 10th Jan 2004

function swapButton(butt1,butt2){

	document.getElementById(butt1).style.display = "none"
	document.getElementById(butt2).style.display = "block"
}



function swapButton2(butt1,butt2){

	document.getElementById(butt1).style.display = "none"
	document.getElementById(butt2).style.display = "inline"
}




/****************************************************/

/****************************************************/
function openPopupCallMeBack(url,size,name,secure) {
	//alert(url)
	var a = arguments;
	// if no parameters are given
	if (!url) return false;
	// if no name parameter is given
	if (!name) name = "win"+Math.round(Math.random()*999);

	var sizeStr = "width=758,height=580";
			

	// find anchor ref

	var anchor = "";
	if(url) {

		var pos = url.indexOf("#");
		if(pos != -1) {
			anchor = url.substring(pos);
			url = url.substring(0, pos);
		}

		if(url.indexOf("?") != -1){
			sepChar = "&"
		}
		else{
			sepChar = "?"
		}
	}


	if(!secure){secure = "no"}
	else{secure = "yes"}


	// open the window

window.open(url+sepChar+'size='+size+anchor,name,"directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status="+ secure +",toolbar=no,"+sizeStr);
	// this returns false so that the href is not processed in the original <a> tag.
	return false;


}
/****************************************************/

/****************************************************/