function Createlink(obj)
{
	var myArray = obj.split(',');
	var size = myArray.length;
	if ( (obj == "") || (obj == "null") || (size < 6) )
	{
		return alert ("insufficient parameter");
	}
	var path		=	myArray[0];
	var productId	=	myArray[1];
	var target		=	myArray[2];
	var external	=	myArray[3];
	var height		=	myArray[4];
	var width		=	myArray[5];

	Loadpage(path, productId, target, external,height,width);
}

function openNewWin(url,winName,winProp,lid,ipath){
 newWin = window.open(url,winName,winProp);
 newWin.focus();
}

function Loadpage(path, tabId, target, external, height, width) {
	var arr=new Array("home", "CreditCards", "Mortgages", "Deposits", "Loans", "Investments", "Insurance", "SuperRetire");

	if ( (!path) || (trim(path) == "") ) {
		return alert ("path cannot be empty or null");
	}

	var queryStringIndex = path.indexOf("?");
	var normalizedPath = (queryStringIndex > 0)?path.substring(0, queryStringIndex):path;

	var isWebServerFile = false;
	var isExternalSite = false;
	height = ( (height == "") || (height == "null") || (!height) )?"534" :height;
	width =  ( (width  == "") || (width  == "null") || (!width)  )?"650" :width;
	tabId =  ( (tabId == "" ) || (tabId == "null" ) || (!tabId)  )?"home":tabId; 
	
	tabId = tabId.replace(/[^A-Za-z0-9\\,]+/, ""); 
	
	//commented to remove externalsite functionality
	/*if(normalizedPath.indexOf("http://") >= 0 || normalizedPath.indexOf("https://") >= 0) {   
		isExternalSite = true;
	}else*/ 
	
	isWebServerFile = true;
	
	if(normalizedPath.indexOf("/info/") == 0 || normalizedPath.indexOf("/prod/") == 0 || normalizedPath.indexOf("/promo/") == 0 || normalizedPath.indexOf("/popup/") == 0 ) {
		isWebServerFile = false;
	}//alert(isWebServerFile)
	
	if(external == "Y" || external == "y"){
    	isExternalSite = true;
    }
	
	var isAppLink = false;
	var isAppLoadPage = true;
	
	if(path.indexOf(".do") >= 0) {
		isAppLink = true;
	}
	
	if(arr.toString().indexOf(tabId) != -1){
        isAppLoadPage = false;	        
    }    
    
    if (isExternalSite) {
    	confirnbox(path,target, height, width);
    }
    else if (target == "0" || target == "null" || target == ""){
        if(!isWebServerFile && !isAppLink) {
        	if(isAppLoadPage)
                //path = "/AUGCB/APPS/portal/LoadAppPage.do?tabId="+tabId+ "&path="+path; 
				path = "/AUGCB/APPS/portal/loadPage.do?tabId="+tabId+ "&path="+path;
            else
                path = "/AUGCB/APPS/portal/loadPage.do?tabId="+tabId+ "&path="+path;
    	}
    	else if(isAppLink){
    		//path = "/AUGCB/"+path;
			if(!(path.indexOf("/AUGCB/")== 0))
				path = "/AUGCB/"+path;
    	}
		//alert(path);
    	top.location.href = path;
    }
	else if (target == "1") {		
		var param = "left=95" + "," + "top=11" + "," + "width=" + width + "," + "height=" + height + "," +"location=yes" + "," +"status=no" +"," +"toolbar=no" + "," + "menubar=no" + "," + "scrollbars=yes";
		if(!isWebServerFile && !isAppLink) {
        	if(isAppLoadPage)
                //path = "/AUGCB/APPS/portal/LoadAppPage.do?tabId="+tabId+ "&path="+path; 
				path = "/AUGCB/APPS/portal/loadPage.do?tabId="+tabId+ "&path="+path;
            else
                path = "/AUGCB/APPS/portal/loadPage.do?tabId="+tabId+ "&path="+path;
    	}
    	else if(isAppLink){
    		//path = "/AUGCB/"+path;
			if(!(path.indexOf("/AUGCB/")== 0))
				path = "/AUGCB/"+path;
    	}  	
		//alert(path);
		window.open(path, "NewWinDow", param); return;
	}
	else if (target == "2") {
		var param = "left=95" + "," + "top=11" + "," + "width=" + width + "," + "height=" + height + "," +"location=yes" + "," +"status=yes" +"," +"toolbar=yes" + "," + "menubar=yes" + "," + "scrollbars=yes,resizable=yes";
		if(!isWebServerFile && !isAppLink) {
        	if(isAppLoadPage)
                //path = "/AUGCB/APPS/portal/LoadAppPage.do?tabId="+tabId+ "&path="+path; 
				path = "/AUGCB/APPS/portal/loadPage.do?tabId="+tabId+ "&path="+path;
            else
                path = "/AUGCB/APPS/portal/loadPage.do?tabId="+tabId+ "&path="+path;
    	}
    	else if(isAppLink){
	   		//path = "/AUGCB/"+path;
			if(!(path.indexOf("/AUGCB/")== 0))
				path = "/AUGCB/"+path;
    	} 	
		//alert(path);
		window.open(path, "NewWinDow", param);	return;		
	}
	else if (target == "3") {		
		if(!isWebServerFile && !isAppLink) {
        	if(isAppLoadPage)
                //path = "/AUGCB/APPS/portal/LoadAppPage.do?tabId="+tabId+ "&path="+path; 
				path = "/AUGCB/APPS/portal/loadPage.do?tabId="+tabId+ "&path="+path;
            else
                path = "/AUGCB/APPS/portal/loadPage.do?tabId="+tabId+ "&path="+path;
    	}
    	else if(isAppLink){
    		//path = "/AUGCB/"+path;
			if(!(path.indexOf("/AUGCB/")== 0))
				path = "/AUGCB/"+path;
    	}
		linkParentAndCloseSelf(path); return;
	}
}
function confirnbox(path,target, height, width)
{
var name = confirm("By clicking \"OK\" you acknowledge that you are leaving a Citibank website to go to a third party website, and that Citibank does not accept any responsibility for the operation of the third party website. Do you wish to continue?")
if (name == true) 
{
if (target == "1")
{
//parm = "left=95,top=11,location=yes,status=no,toolbar=no,menubar=no,scrollbars=yes,"+"width="+width+","+"height="+height;
var parm = "left=95" + "," + "top=11" + "," + "width=" + width + "," + "height=" + height + "," +"location=yes" + "," +"status=no" +"," +"toolbar=no" + "," + "menubar=no" + "," + "scrollbars=yes";
window.open(path,'NewWinDow', parm);
return ;
}
else if(target == "2")
{
//var parm = "left=95,location=yes,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,"+ "width="+width+","+"height="+height;
var parm = "left=95" + "," + "top=11" + "," + "width=" + width + "," + "height=" + height + "," +"location=yes" + "," +"status=yes" +"," +"toolbar=yes" + "," + "menubar=yes" + "," + "scrollbars=yes,resizable=yes";
window.open(path,'NewWinDow', parm);
return;
}
else
{
window.location=path;
}
}
else
{
return ;
}
}
function trim(inputString) {
var newInputString = replace(inputString,'%20',' ');  
if (typeof newInputString != "string") { return newInputString; }
var retValue = newInputString;
var ch = retValue.substring(0, 1);
while (ch == " ") { 
retValue = retValue.substring(1, retValue.length);
ch = retValue.substring(0, 1);
}
ch = retValue.substring(retValue.length-1, retValue.length);
while (ch == " ") { 
retValue = retValue.substring(0, retValue.length-1);
ch = retValue.substring(retValue.length-1, retValue.length);
}
while (retValue.indexOf(" ") != -1) { 
retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); 
}
return retValue; 
}
function replace(string,text,by) {
var strLength = string.length, txtLength = text.length;
if ((strLength == 0) || (txtLength == 0)) 
return string;
var i = string.indexOf(text);
if ((!i) && (text != string.substring(0,txtLength))) return string;
if (i == -1) return string;
var newstr = string.substring(0,i) + by;
if (i+txtLength < strLength)
newstr += replace(string.substring(i+txtLength,strLength),text,by);
return newstr;
}

