function ResetFrame()
{
    try 
    {
        //If 'self' is not the top frame then check self is contained within a 
        //frame called 'CSiDirresFrame' if not then reframe the browser
	    if(top != self && self.name.toLowerCase() != "csidirresframe") 
	    {
	        var queryStr = document.location.search.substring(1);
		    var arrayQuery = queryStr.toLowerCase().split("&");
		    var newURL = "";
    		
		    for(var i = 0; i < arrayQuery.length; i++)
		    {
			    if(arrayQuery[i].indexOf("companyid" ) > -1) newURL = newURL + "&" + arrayQuery[i];
			    if(arrayQuery[i].indexOf("customerid") > -1) newURL = newURL + "&" + arrayQuery[i];
			    if(arrayQuery[i].indexOf("confirmid") > -1) newURL = newURL + "&" + arrayQuery[i];
			    if(arrayQuery[i].indexOf("returnurl") > -1) newURL = newURL + "&" + arrayQuery[i];
			    if(arrayQuery[i].indexOf("url") > -1) newURL = newURL + "&" + arrayQuery[i];
		    }
    		
		    if(newURL.length > 0) newURL = "?" + newURL.substring(1);
    		
		    var pathStr = self.location.pathname;
		    pathStr = pathStr.substr(0, pathStr.lastIndexOf("/"));
    		
		    top.location.href = self.location.protocol + "//" + self.location.host + pathStr + "/Default.aspx" + newURL;
	    }
    }
    catch (e) 
    {
        //Make sure the error does not sent the pages in a recurring loop
        var loc = self.location.protocol + "//" + self.location.host + "/Default.aspx";
        if (top.location.href.toLowerCase() != loc.toLowerCase())
        {
            top.location.href = loc;
        }
    }
}

ResetFrame();
