function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=838,height=628');");
}

function openPopup(url, name) {
        popupWin = window.open(url, name, 'scrollbars,resizable,width=480,height=320');
        window.self.name = 'cnetParent';
}

function downloadNow(file,redUrl,extUrl) {
    var isIe = (window.navigator.userAgent.toUpperCase().indexOf('MSIE') != -1);
    var isOpera = (window.navigator.userAgent.toUpperCase().indexOf('OPERA') != -1);

    if (isIe && extUrl == 0 && !isOpera) {
        window.open(file,'dlnow','toolbar=0,location=no,directories=0,status=0, scrollbars=no,resizable=0,width=1,height=1,top=0,left=0');
        window.focus();
        location.href = redUrl + '?idl=n';
    } else {
        location.href = redUrl;
    }
}

function dlNow(file,redUrl,extUrl) {
    // skip if external url or old browser
   // if (extUrl == 0 && document.readyState) {
        // first try to download file in same window    
   //     location.href = file;
        // mozilla readyState is always undefined
        // safari readyState is always complete
        // ie readyState is loading -> interactive -> complete
   //     if (document.readyState && document.readyState == 'loading') {
            // possible to detect when download dialog starts
            // check readyState every 250ms and
            // redirect to post download page with initiate download disabled
    //        setTimeout('dlComplete(\'' + redUrl + '%3Fidl=n\')', 250);
    //        return false;
    //    }
    //}
    // not possible to detect when download dialog starts
    // just follow href to post download page and let it initiate the download
    //location.href = redUrl;
    //return true;   
    newDLNow(file,redUrl,extUrl);
    return false;
}	

function dlComplete(redUrl) {
    if (document.readyState == 'loading') {
	/*window.onunload=function(){
		//alert("unloading in dlComplete: " + document.readyState);
		//if (document.readyState == 'loading') {		
			// this means the file url is bad
			// redirect to post download page
			redUrl = redUrl.substring(0,redUrl.indexOf('%3Fidl=n'));			
			location.href = redUrl;
		//}
	} */   
        // still loading, check again in 250ms        
        setTimeout('dlComplete(\'' + redUrl + '\')', 100);
    } else {
        // readyState = interactive or complete means download dialog started
        // redirect to post download page with initiate download disabled        
        location.href = redUrl;
    }    
}

function newDLNow(file,redUrl,extUrl) { 
//file = "ftp://ftp.download.com/pub/ppd/10306590-10415721/htfireman20shasdsfdsfdreeng.exe";
    var isIe = (window.navigator.userAgent.toUpperCase().indexOf('MSIE') != -1);
    var isOpera = (window.navigator.userAgent.toUpperCase().indexOf('OPERA') != -1);   

    if (isIe && extUrl == 0 && !isOpera) {  	
	myDLWindow = window.open(file,'_blank','toolbar=0,location=no,directories=0,status=0, scrollbars=no,resizable=0,width=0,height=0,top=0,left=0');               	     
	location.href = redUrl + '?idl=n';                    
    } else {
    	//alert('this is not ie, is an ext url, or is Opera');
        location.href = redUrl;
    }    
}

//sniffs out Safari
var isSafari=(navigator.userAgent.indexOf('Safari')>=0)?true:false;
if (isSafari == true) {
	//alert("Safari");
	document.write("<style>#cobr-header #search-bar .search-fields .input-search {float: left; width: 100px; padding: 0; margin: 2px 5px 0 7px;}</style>");
}       
               